fix: tests
ref: N25B-334
This commit is contained in:
@@ -62,11 +62,11 @@ def test_receive_speech_command_success(client):
|
||||
speech_command = SpeechCommand(**command_data)
|
||||
|
||||
# Act
|
||||
response = client.post("/command", json=command_data)
|
||||
response = client.post("/command/speech", json=command_data)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 202
|
||||
assert response.json() == {"status": "Command received"}
|
||||
assert response.json() == {"status": "Speech command received"}
|
||||
|
||||
# Verify that the ZMQ socket was used correctly
|
||||
mock_pub_socket.send_multipart.assert_awaited_once_with(
|
||||
@@ -87,11 +87,11 @@ def test_receive_gesture_command_success(client):
|
||||
gesture_command = GestureCommand(**command_data)
|
||||
|
||||
# Act
|
||||
response = client.post("/command", json=command_data)
|
||||
response = client.post("/command/gesture", json=command_data)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 202
|
||||
assert response.json() == {"status": "Command received"}
|
||||
assert response.json() == {"status": "Gesture command received"}
|
||||
|
||||
# Verify that the ZMQ socket was used correctly
|
||||
mock_pub_socket.send_multipart.assert_awaited_once_with(
|
||||
@@ -99,13 +99,23 @@ def test_receive_gesture_command_success(client):
|
||||
)
|
||||
|
||||
|
||||
def test_receive_command_invalid_payload(client):
|
||||
def test_receive_speech_command_invalid_payload(client):
|
||||
"""
|
||||
Test invalid data handling (schema validation).
|
||||
"""
|
||||
# Missing required field(s)
|
||||
bad_payload = {"invalid": "data"}
|
||||
response = client.post("/command", json=bad_payload)
|
||||
response = client.post("/command/speech", json=bad_payload)
|
||||
assert response.status_code == 422 # validation error
|
||||
|
||||
|
||||
def test_receive_gesture_command_invalid_payload(client):
|
||||
"""
|
||||
Test invalid data handling (schema validation).
|
||||
"""
|
||||
# Missing required field(s)
|
||||
bad_payload = {"invalid": "data"}
|
||||
response = client.post("/command/gesture", json=bad_payload)
|
||||
assert response.status_code == 422 # validation error
|
||||
|
||||
|
||||
@@ -243,7 +253,7 @@ async def test_get_available_gesture_tags_success(client, monkeypatch):
|
||||
monkeypatch.setattr(robot.logger, "error", MagicMock())
|
||||
|
||||
# Act
|
||||
response = client.get("/get_available_gesture_tags")
|
||||
response = client.get("/commands/gesture/tags")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
@@ -276,7 +286,7 @@ async def test_get_available_gesture_tags_with_amount(client, monkeypatch):
|
||||
monkeypatch.setattr(robot.logger, "error", MagicMock())
|
||||
|
||||
# Act
|
||||
response = client.get("/get_available_gesture_tags")
|
||||
response = client.get("/commands/gesture/tags")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
@@ -308,7 +318,7 @@ async def test_get_available_gesture_tags_timeout(client, monkeypatch):
|
||||
monkeypatch.setattr(robot.logger, "error", MagicMock())
|
||||
|
||||
# Act
|
||||
response = client.get("/get_available_gesture_tags")
|
||||
response = client.get("/commands/gesture/tags")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
@@ -342,7 +352,7 @@ async def test_get_available_gesture_tags_empty_response(client, monkeypatch):
|
||||
monkeypatch.setattr(robot.logger, "error", MagicMock())
|
||||
|
||||
# Act
|
||||
response = client.get("/get_available_gesture_tags")
|
||||
response = client.get("/commands/gesture/tags")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
@@ -369,7 +379,7 @@ async def test_get_available_gesture_tags_missing_tags_key(client, monkeypatch):
|
||||
monkeypatch.setattr(robot.logger, "error", MagicMock())
|
||||
|
||||
# Act
|
||||
response = client.get("/get_available_gesture_tags")
|
||||
response = client.get("/commands/gesture/tags")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
@@ -397,7 +407,7 @@ async def test_get_available_gesture_tags_invalid_json(client, monkeypatch):
|
||||
monkeypatch.setattr(robot.logger, "debug", MagicMock())
|
||||
|
||||
# Act
|
||||
response = client.get("/get_available_gesture_tags")
|
||||
response = client.get("/commands/gesture/tags")
|
||||
|
||||
# Assert - invalid JSON should lead to empty list and error log invocation
|
||||
assert response.status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user