chore: applied all feedback

close: N25B-298
This commit is contained in:
Pim Hutting
2025-11-22 11:45:32 +01:00
parent 051f904576
commit c53307530b
12 changed files with 53 additions and 212 deletions

View File

@@ -24,12 +24,6 @@ def zmq_context():
def test_no_microphone(zmq_context, mocker):
"""
Tests the scenario where no valid microphone can be chosen for recording.
:param zmq_context: The ZeroMQ context fixture.
:type zmq_context: zmq.Context
:param mocker: The pytest-mock fixture used to patch internal dependencies.
:type mocker: pytest_mock.plugin.MockerFixture
"""
mock_info_logger = mocker.patch("robot_interface.endpoints.audio_sender.logger.info")
mock_choose_mic = mocker.patch("robot_interface.endpoints.audio_sender.choose_mic")
@@ -49,12 +43,6 @@ def test_unicode_mic_name(zmq_context, mocker):
"""
Tests the robustness of the `AudioSender` when handling microphone names
that contain Unicode characters.
:param zmq_context: The ZeroMQ context fixture.
:type zmq_context: zmq.Context
:param mocker: The pytest-mock fixture used to patch internal dependencies.
:type mocker: pytest_mock.plugin.MockerFixture
"""
mocker.patch("robot_interface.endpoints.audio_sender.threading")
mock_choose_mic = mocker.patch("robot_interface.endpoints.audio_sender.choose_mic")
@@ -74,12 +62,6 @@ def test_unicode_mic_name(zmq_context, mocker):
def _fake_read(num_frames):
"""
Helper function to simulate reading raw audio data from a microphone stream.
:param num_frames: The number of audio frames requested.
:type num_frames: int
:return: A byte string containing random data, simulating audio.
:rtype: str
"""
return os.urandom(num_frames * 4)
@@ -87,9 +69,6 @@ def _fake_read(num_frames):
def test_sending_audio(mocker):
"""
Tests the successful sending of audio data over a ZeroMQ socket.
:param mocker: The pytest-mock fixture used to patch internal dependencies.
:type mocker: pytest_mock.plugin.MockerFixture
"""
mock_choose_mic = mocker.patch("robot_interface.endpoints.audio_sender.choose_mic")
mock_choose_mic.return_value = {"name": u"Some mic", "index": 0L}
@@ -118,9 +97,6 @@ def test_sending_audio(mocker):
def _fake_read_error(num_frames):
"""
Helper function to simulate an I/O error during microphone stream reading.
:param num_frames: The number of audio frames requested.
:type num_frames: int
"""
raise IOError()
@@ -128,9 +104,6 @@ def _fake_read_error(num_frames):
def test_break_microphone(mocker):
"""
Tests the error handling when the microphone stream breaks (raises an IOError).
:param mocker: The pytest-mock fixture used to patch internal dependencies.
:type mocker: pytest_mock.plugin.MockerFixture
"""
mock_choose_mic = mocker.patch("robot_interface.endpoints.audio_sender.choose_mic")
mock_choose_mic.return_value = {"name": u"Some mic", "index": 0L}