Esempio n. 1
0
    async def test_can_send_frame(self):
        stomp = StompReader(None, self.loop)
        stomp._transport = Mock()

        stomp.send_frame('SUBSCRIBE', {'ack': 'auto'}, 'ç')

        stomp._transport.write.assert_called_with(b'SUBSCRIBE\n'
                                                  b'ack:auto\n'
                                                  b'\n'
                                                  b'\xc3\xa7\x00')
Esempio n. 2
0
    async def test_can_send_frame(self):
        stomp = StompReader(None, self.loop)
        stomp._transport = Mock()

        stomp.send_frame("SUBSCRIBE", {"ack": "auto"}, "ç")

        stomp._transport.write.assert_called_with(b"SUBSCRIBE\n"
                                                  b"ack:auto\n"
                                                  b"\n"
                                                  b"\xc3\xa7\x00")
Esempio n. 3
0
    async def test_can_connect(self):
        stomp = StompReader(None,
                            self.loop,
                            heartbeat={
                                "enabled": True,
                                "cx": 1000,
                                "cy": 1000
                            })
        stomp._transport = Mock()

        stomp.connect()
        stomp._transport.write.assert_called_with(
            b"CONNECT\naccept-version:1.1\nheart-beat:1000,1000\n\n\x00")
Esempio n. 4
0
    async def test_can_connect_with_password(self):
        stomp = StompReader(None,
                            self.loop,
                            heartbeat={
                                'enabled': True,
                                'cx': 1000,
                                'cy': 1000
                            },
                            password='******')
        stomp._transport = Mock()

        stomp.connect()
        stomp._transport.write.assert_called_with(
            b'CONNECT\naccept-version:1.1\nheart-beat:1000,1000\npasscode:pass\n\n\x00'
        )  # noqa
Esempio n. 5
0
    async def test_can_connect_with_username(self):
        stomp = StompReader(None,
                            self.loop,
                            heartbeat={
                                'enabled': True,
                                'cx': 1000,
                                'cy': 1000
                            },
                            username='******')
        stomp._transport = Mock()

        stomp.connect()
        stomp._transport.write.assert_called_with(
            b'CONNECT\naccept-version:1.1\nheart-beat:1000,1000\nlogin:pkiefer\n\n\x00'
        )  # noqa
Esempio n. 6
0
    async def test_can_handle_connected_frame_with_heartbeat_disabled(
            self, heartbeater_klass_mock):
        frame = Frame("CONNECTED", {"heart-beat": "1000,1000"}, "{}")

        heartbeater_mock = heartbeater_klass_mock.return_value
        heartbeater_mock.start = CoroutineMock()

        stomp = StompReader(None,
                            self.loop,
                            heartbeat={
                                "enabled": False,
                                "cx": 0,
                                "cy": 0
                            })
        stomp._transport = Mock()
        await stomp._handle_connect(frame)

        heartbeater_klass_mock.assert_not_called
Esempio n. 7
0
    async def test_can_connect_with_login_pass(self):
        stomp = StompReader(
            None,
            self.loop,
            heartbeat={
                "enabled": True,
                "cx": 1000,
                "cy": 1000
            },
            username="******",
            password="******",
        )
        stomp._transport = Mock()

        stomp.connect()
        stomp._transport.write.assert_called_with(
            b"CONNECT\naccept-version:1.1\nheart-beat:1000,1000\nlogin:pkiefer\npasscode:pass\n\n\x00"
        )  # noqa
Esempio n. 8
0
    async def test_can_handle_connected_frame_with_heartbeat_disabled(
            self, heartbeater_klass_mock):
        frame = Frame('CONNECTED', {'heart-beat': '1000,1000'}, '{}')

        heartbeater_mock = heartbeater_klass_mock.return_value
        heartbeater_mock.start = CoroutineMock()

        stomp = StompReader(None,
                            self.loop,
                            heartbeat={
                                'enabled': False,
                                'cx': 0,
                                'cy': 0
                            })
        stomp._transport = Mock()
        await stomp._handle_connect(frame)

        heartbeater_klass_mock.assert_not_called
Esempio n. 9
0
    async def test_send_frame_can_raise_error(self):
        stomp = StompReader(None, self.loop)
        stomp._transport = None

        with self.assertRaises(StompDisconnectedError):
            stomp.send_frame("SUBSCRIBE", {"ack": "auto"}, "ç")
Esempio n. 10
0
    async def test_send_frame_can_raise_error(self):
        stomp = StompReader(None, self.loop)
        stomp._transport = None

        with self.assertRaises(StompDisconnectedError):
            stomp.send_frame('SUBSCRIBE', {'ack': 'auto'}, 'ç')