def test_write_message_incorrect_request(mock_write): ac = ActiveConnections() app = tornado.web.Application() app.active_connections = ac r = MockRequest() r.path = '/myuser.js' r.uri = 'http://example.com/myuser.js' mh = MainHandler(app, r) mh.write_message() assert mock_write.call_count == 0, 'Wrote incorrect message'
def test_write_message(mock_write): ac = ActiveConnections() app = tornado.web.Application() app.active_connections = ac r = MockRequest() r.path = '/myuser/somepath.js' r.uri = 'http://example.com/myuser/somepath.js' mh = MainHandler(app, r) mh.write_message() mock_write.assert_called_once_with({ 'type': 'message', 'user': '******', 'file': 'somepath.js', 'uri': 'http://example.com/myuser/somepath.js' })