feat: parameterize RI host
Was "localhost" in RI Communication Agent, now uses configurable setting. Secretly also removing "localhost" from VAD agent, as its socket should be something that's "inproc". ref: N25B-352
This commit is contained in:
@@ -91,7 +91,7 @@ def test_out_socket_creation(zmq_context):
|
||||
assert per_vad_agent.audio_out_socket is not None
|
||||
|
||||
zmq_context.return_value.socket.assert_called_once_with(zmq.PUB)
|
||||
zmq_context.return_value.socket.return_value.bind_to_random_port.assert_called_once()
|
||||
zmq_context.return_value.socket.return_value.bind.assert_called_once_with("inproc://vad_stream")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
@@ -7,6 +7,15 @@ import zmq
|
||||
from control_backend.agents.perception.vad_agent import VADAgent
|
||||
|
||||
|
||||
# We don't want to use real ZMQ in unit tests, for example because it can give errors when sockets
|
||||
# aren't closed properly.
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_zmq():
|
||||
with patch("zmq.asyncio.Context") as mock:
|
||||
mock.instance.return_value = MagicMock()
|
||||
yield mock
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def audio_out_socket():
|
||||
return AsyncMock()
|
||||
@@ -140,12 +149,10 @@ async def test_vad_model_load_failure_stops_agent(vad_agent):
|
||||
# Patch stop to an AsyncMock so we can check it was awaited
|
||||
vad_agent.stop = AsyncMock()
|
||||
|
||||
result = await vad_agent.setup()
|
||||
await vad_agent.setup()
|
||||
|
||||
# Assert stop was called
|
||||
vad_agent.stop.assert_awaited_once()
|
||||
# Assert setup returned None
|
||||
assert result is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -155,7 +162,7 @@ async def test_audio_out_bind_failure_sets_none_and_logs(vad_agent, caplog):
|
||||
audio_out_socket is set to None, None is returned, and an error is logged.
|
||||
"""
|
||||
mock_socket = MagicMock()
|
||||
mock_socket.bind_to_random_port.side_effect = zmq.ZMQBindError()
|
||||
mock_socket.bind.side_effect = zmq.ZMQBindError()
|
||||
with patch("control_backend.agents.perception.vad_agent.azmq.Context.instance") as mock_ctx:
|
||||
mock_ctx.return_value.socket.return_value = mock_socket
|
||||
|
||||
|
||||
Reference in New Issue
Block a user