Skip to content

Commit

Permalink
Test exception logging in WSClientComms message handling
Browse files Browse the repository at this point in the history
  • Loading branch information
c-mita committed Jul 1, 2016
1 parent 089479f commit 2518a3e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_wscomms/test_wsclientcomms.py
Expand Up @@ -62,6 +62,19 @@ def test_on_message(self, _, _1, json_mock, response_mock):
response_mock.from_dict.assert_called_once_with(message_dict)
request_mock.response_queue.put.assert_called_once_with(response)

@patch('malcolm.wscomms.wsclientcomms.json')
@patch('malcolm.wscomms.wsclientcomms.websocket_connect')
@patch('malcolm.wscomms.wsclientcomms.IOLoop')
def test_on_message_logs_exception(self, _, _1, json_mock):
self.WS = WSClientComms("TestWebSocket", self.p, "test/url")
self.WS.log_exception = MagicMock()
exception = Exception()
json_mock.loads.side_effect = exception

self.WS.on_message("test")

self.WS.log_exception.assert_called_once_with(exception)

@patch('malcolm.wscomms.wsclientcomms.json')
@patch('malcolm.wscomms.wsclientcomms.websocket_connect')
@patch('malcolm.wscomms.wsclientcomms.IOLoop')
Expand Down

0 comments on commit 2518a3e

Please sign in to comment.