fix: make VAD unit tests work with minimal dependencies

By mocking PyTorch and ZMQ and adding the Numpy dependency.

ref: N25B-213
This commit is contained in:
Twirre Meulenbelt
2025-10-28 18:13:00 +01:00
parent fd1facedd1
commit f73f510608
4 changed files with 19 additions and 0 deletions

View File

@@ -18,6 +18,9 @@ def audio_out_socket():
@pytest.fixture
def streaming(audio_in_socket, audio_out_socket):
import torch
torch.hub.load.return_value = (..., ...) # Mock
return Streaming(audio_in_socket, audio_out_socket)

View File

@@ -33,3 +33,13 @@ def pytest_configure(config):
mock_config_module.settings = MagicMock()
sys.modules["control_backend.core.config"] = mock_config_module
# --- Mock torch and zmq for VAD ---
mock_torch = MagicMock()
mock_zmq = MagicMock()
mock_zmq.asyncio = mock_zmq
# In individual tests, these can be imported and the return values changed
sys.modules["torch"] = mock_torch
sys.modules["zmq"] = mock_zmq
sys.modules["zmq.asyncio"] = mock_zmq.asyncio