chore: add documentation RI
Code functionality left unchanged, only added docs where missing close: N25B-298
This commit is contained in:
@@ -9,11 +9,24 @@ from robot_interface.endpoints.actuation_receiver import ActuationReceiver
|
||||
|
||||
@pytest.fixture
|
||||
def zmq_context():
|
||||
"""
|
||||
A pytest fixture that creates and yields a ZMQ context.
|
||||
|
||||
:return: An initialized ZeroMQ context.
|
||||
:rtype: zmq.Context
|
||||
"""
|
||||
context = zmq.Context()
|
||||
yield context
|
||||
|
||||
|
||||
def test_handle_unimplemented_endpoint(zmq_context):
|
||||
"""
|
||||
Tests that the ``ActuationReceiver.handle_message`` method can
|
||||
handle an unknown or unimplemented endpoint without raising an error.
|
||||
|
||||
:param zmq_context: The ZeroMQ context fixture.
|
||||
:type zmq_context: zmq.Context
|
||||
"""
|
||||
receiver = ActuationReceiver(zmq_context)
|
||||
# Should not error
|
||||
receiver.handle_message({
|
||||
@@ -23,6 +36,16 @@ def test_handle_unimplemented_endpoint(zmq_context):
|
||||
|
||||
|
||||
def test_speech_message_no_data(zmq_context, mocker):
|
||||
"""
|
||||
Tests that the message handler logs a warning when a speech actuation
|
||||
request (`actuate/speech`) is received but contains empty string data.
|
||||
|
||||
:param zmq_context: The ZeroMQ context fixture.
|
||||
:type zmq_context: zmq.Context
|
||||
|
||||
:param mocker: The pytest-mock fixture used to patch `logging.warn`.
|
||||
:type mocker: pytest_mock.plugin.MockerFixture
|
||||
"""
|
||||
mock_warn = mocker.patch("logging.warn")
|
||||
|
||||
receiver = ActuationReceiver(zmq_context)
|
||||
@@ -32,6 +55,16 @@ def test_speech_message_no_data(zmq_context, mocker):
|
||||
|
||||
|
||||
def test_speech_message_invalid_data(zmq_context, mocker):
|
||||
"""
|
||||
Tests that the message handler logs a warning when a speech actuation
|
||||
request (`actuate/speech`) is received with data that is not a string (e.g., a boolean).
|
||||
|
||||
:param zmq_context: The ZeroMQ context fixture.
|
||||
:type zmq_context: zmq.Context
|
||||
|
||||
:param mocker: The pytest-mock fixture used to patch `logging.warn`.
|
||||
:type mocker: pytest_mock.plugin.MockerFixture
|
||||
"""
|
||||
mock_warn = mocker.patch("logging.warn")
|
||||
|
||||
receiver = ActuationReceiver(zmq_context)
|
||||
@@ -41,6 +74,16 @@ def test_speech_message_invalid_data(zmq_context, mocker):
|
||||
|
||||
|
||||
def test_speech_no_qi(zmq_context, mocker):
|
||||
"""
|
||||
Tests the actuation receiver's behavior when processing a speech request
|
||||
but the global state does not have an active QI session.
|
||||
|
||||
:param zmq_context: The ZeroMQ context fixture.
|
||||
:type zmq_context: zmq.Context
|
||||
|
||||
:param mocker: The pytest-mock fixture used to patch the global state.
|
||||
:type mocker: pytest_mock.plugin.MockerFixture
|
||||
"""
|
||||
mock_state = mocker.patch("robot_interface.endpoints.actuation_receiver.state")
|
||||
|
||||
mock_qi_session = mock.PropertyMock(return_value=None)
|
||||
@@ -53,6 +96,16 @@ def test_speech_no_qi(zmq_context, mocker):
|
||||
|
||||
|
||||
def test_speech(zmq_context, mocker):
|
||||
"""
|
||||
Tests the core speech actuation functionality by mocking the QI TextToSpeech
|
||||
service and verifying that it is called correctly.
|
||||
|
||||
:param zmq_context: The ZeroMQ context fixture.
|
||||
:type zmq_context: zmq.Context
|
||||
|
||||
:param mocker: The pytest-mock fixture used to patch state and modules.
|
||||
:type mocker: pytest_mock.plugin.MockerFixture
|
||||
"""
|
||||
mock_state = mocker.patch("robot_interface.endpoints.actuation_receiver.state")
|
||||
|
||||
mock_qi = mock.Mock()
|
||||
|
||||
Reference in New Issue
Block a user