Exemple #1
0
    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"}')])
Exemple #3
0
    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, {})
    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, {})