def test_remote_close_exc_in_handler(self): handler = self.make_handler([], exc=True) session = self.make_session(handler=handler) self.loop.run_until_complete(session._remote_close()) self.assertFalse(session.interrupted) self.assertEqual(session.state, protocol.STATE_CLOSING)
def test_remote_close_idempotent(self): messages = [] session = self.make_session(result=messages) session.state = protocol.STATE_CLOSED self.loop.run_until_complete(session._remote_close()) self.assertEqual(session.state, protocol.STATE_CLOSED) self.assertEqual(messages, [])
def test_remote_close(self): messages = [] session = self.make_session(result=messages) self.loop.run_until_complete(session._remote_close()) self.assertFalse(session.interrupted) self.assertEqual(session.state, protocol.STATE_CLOSING) self.assertEqual( messages, [(protocol.SockjsMessage( tp=protocol.MSG_CLOSE, data=None), session)])
def test_remote_close_with_exc(self): messages = [] session = self.make_session(result=messages) exc = ValueError() self.loop.run_until_complete(session._remote_close(exc=exc)) self.assertTrue(session.interrupted) self.assertEqual(session.state, protocol.STATE_CLOSING) self.assertEqual( messages, [(protocol.SockjsMessage(tp=protocol.MSG_CLOSE, data=exc), session)])