def test_ping(self): protocol = RelayProtocol({ 'self': { 'id': 'the-user-id', }, }) protocol.clock = Clock() protocol.factory = Mock() protocol.sendMessage = Mock() protocol.onOpen() protocol.clock.advance(3) protocol.sendMessage.assert_has_calls( [call('{"type": "ping"}'), call('{"type": "ping"}')])
def test_ping(self): protocol = RelayProtocol({ 'self': { 'id': 'the-user-id', }, }) protocol.clock = Clock() protocol.factory = Mock() protocol.sendMessage = Mock() protocol.onOpen() protocol.clock.advance(3) protocol.sendMessage.assert_has_calls([ call('{"type": "ping"}'), call('{"type": "ping"}')])
def test_protocol_close(self): _, r = yield self.mk_relay() protocol = RelayProtocol({ 'self': { 'id': 'the-user-id', }, }) protocol.factory = Mock() protocol.bot_user_id = 'bot-user-id' protocol.relay = r r.set_protocol('bot-user-id', protocol) protocol.onClose(True, None, None) self.assertEqual(r.connections, {})