diff --git a/tests/unit/test_gateway/test_dispatch_mux.py b/tests/unit/test_gateway/test_dispatch_mux.py index bcd0b42d..72c0f2e3 100644 --- a/tests/unit/test_gateway/test_dispatch_mux.py +++ b/tests/unit/test_gateway/test_dispatch_mux.py @@ -101,7 +101,7 @@ class TestMux: async def test_mux_receive_message_without_request(self): """Test Mux receive method with message missing request field""" mock_dispatcher_manager = MagicMock() - mock_ws = MagicMock() + mock_ws = AsyncMock() mock_running = MagicMock() mux = Mux( @@ -119,12 +119,14 @@ class TestMux: # receive method should handle the RuntimeError internally # Based on the code, it seems to catch exceptions await mux.receive(mock_msg) + + mock_ws.send_json.assert_called_once_with({"error": "Bad message"}) @pytest.mark.asyncio async def test_mux_receive_message_without_id(self): """Test Mux receive method with message missing id field""" mock_dispatcher_manager = MagicMock() - mock_ws = MagicMock() + mock_ws = AsyncMock() mock_running = MagicMock() mux = Mux( @@ -141,12 +143,14 @@ class TestMux: # receive method should handle the RuntimeError internally await mux.receive(mock_msg) + + mock_ws.send_json.assert_called_once_with({"error": "Bad message"}) @pytest.mark.asyncio async def test_mux_receive_invalid_json(self): """Test Mux receive method with invalid JSON""" mock_dispatcher_manager = MagicMock() - mock_ws = MagicMock() + mock_ws = AsyncMock() mock_running = MagicMock() mux = Mux( @@ -162,4 +166,5 @@ class TestMux: # receive method should handle the ValueError internally await mux.receive(mock_msg) - mock_msg.json.assert_called_once() \ No newline at end of file + mock_msg.json.assert_called_once() + mock_ws.send_json.assert_called_once_with({"error": "Invalid JSON"}) \ No newline at end of file