diff --git a/test/integration/agents/vad_agent/test_vad_agent.py b/test/integration/agents/vad_agent/test_vad_agent.py index 293912e..54c9d82 100644 --- a/test/integration/agents/vad_agent/test_vad_agent.py +++ b/test/integration/agents/vad_agent/test_vad_agent.py @@ -1,3 +1,4 @@ +import random from unittest.mock import AsyncMock, MagicMock, patch import pytest @@ -17,11 +18,16 @@ def streaming(mocker): return mocker.patch("control_backend.agents.vad_agent.Streaming") +@pytest.fixture +def transcription_agent(mocker): + return mocker.patch("control_backend.agents.vad_agent.TranscriptionAgent", autospec=True) + + @pytest.mark.asyncio -async def test_normal_setup(streaming): +async def test_normal_setup(streaming, transcription_agent): """ Test that during normal setup, the VAD agent creates a Streaming behavior and creates audio - sockets. + sockets, and starts the TranscriptionAgent without loading real models. """ vad_agent = VADAgent("tcp://localhost:12345", False) vad_agent.add_behaviour = MagicMock() @@ -30,6 +36,8 @@ async def test_normal_setup(streaming): streaming.assert_called_once() vad_agent.add_behaviour.assert_called_once_with(streaming.return_value) + transcription_agent.assert_called_once() + transcription_agent.return_value.start.assert_called_once() assert vad_agent.audio_in_socket is not None assert vad_agent.audio_out_socket is not None @@ -85,11 +93,12 @@ async def test_out_socket_creation_failure(zmq_context): @pytest.mark.asyncio -async def test_stop(zmq_context): +async def test_stop(zmq_context, transcription_agent): """ Test that when the VAD agent is stopped, the sockets are closed correctly. """ vad_agent = VADAgent("tcp://localhost:12345", False) + zmq_context.socket.return_value.bind_to_random_port.return_value = random.randint(1000, 10000) await vad_agent.setup() await vad_agent.stop()