Update tests - were coded against invalid protocol messages

This commit is contained in:
Cyber MacGeddon 2026-03-28 10:50:32 +00:00
parent 84886512f9
commit 34360f0a85

View file

@ -121,7 +121,11 @@ class TestMux:
# Based on the code, it seems to catch exceptions # Based on the code, it seems to catch exceptions
await mux.receive(mock_msg) await mux.receive(mock_msg)
mock_ws.send_json.assert_called_once_with({"error": "Bad message"}) mock_ws.send_json.assert_called_once_with({
"error": {"message": "Bad message", "type": "error"},
"complete": True,
"id": "test-id-123",
})
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_mux_receive_message_without_id(self): async def test_mux_receive_message_without_id(self):
@ -145,7 +149,10 @@ class TestMux:
# receive method should handle the RuntimeError internally # receive method should handle the RuntimeError internally
await mux.receive(mock_msg) await mux.receive(mock_msg)
mock_ws.send_json.assert_called_once_with({"error": "Bad message"}) mock_ws.send_json.assert_called_once_with({
"error": {"message": "Bad message", "type": "error"},
"complete": True,
})
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_mux_receive_invalid_json(self): async def test_mux_receive_invalid_json(self):
@ -168,4 +175,7 @@ class TestMux:
await mux.receive(mock_msg) await mux.receive(mock_msg)
mock_msg.json.assert_called_once() mock_msg.json.assert_called_once()
mock_ws.send_json.assert_called_once_with({"error": "Invalid JSON"}) mock_ws.send_json.assert_called_once_with({
"error": {"message": "Invalid JSON", "type": "error"},
"complete": True,
})