import pytest from voice_assistant.stt.mock import MockSTTAdapter @pytest.mark.anyio async def test_mock_stt_lifecycle(): stt = MockSTTAdapter() await stt.start_session() await stt.send_audio(b"\x00\x00" * 160) await stt.emit_partial("eu gostaria de saber") await stt.emit_final( "eu gostaria de saber o horĂ¡rio de funcionamento" ) await stt.stop_session() events = [event async for event in stt.events()] assert len(events) == 2 assert events[0].type == "partial" assert events[0].text == "eu gostaria de saber" assert events[1].type == "final" assert events[1].text == ( "eu gostaria de saber o horĂ¡rio de funcionamento" ) @pytest.mark.anyio async def test_mock_stt_rejects_audio_before_start(): stt = MockSTTAdapter() with pytest.raises(RuntimeError, match="has not been started"): await stt.send_audio(b"\x00\x00")