Esempio n. 1
0
    def test_receive_connected(self):
        client = AsyncClient()
        frame = Frame(Command.CONNECTED,
                      {'version': '1.2', Headers.HEARTBEAT: '8000,0'})

        client.handle_frame(FakeAsyncDispatcher(''), frame)

        self.assertTrue(client.connected)
Esempio n. 2
0
    def test_receive_connected(self):
        client = AsyncClient()
        frame = Frame(Command.CONNECTED, {
            'version': '1.2',
            Headers.HEARTBEAT: '8000,0'
        })

        client.handle_frame(FakeAsyncDispatcher(''), frame)

        self.assertTrue(client.connected)
Esempio n. 3
0
    def test_receive_message(self):
        client = AsyncClient()
        id = 'ad052acb-a934-4e10-8ec3-00c7417ef8d1'
        headers = {Headers.CONTENT_LENGTH: '78',
                   Headers.DESTINATION: 'jms.topic.vdsm_responses',
                   Headers.CONTENT_TYPE: 'application/json',
                   Headers.SUBSCRIPTION: id}
        body = ('{"jsonrpc": "2.0", "id": "e8a936a6-d886-4cfa-97b9-2d54209053f'
                'f", "result": []}')
        frame = Frame(command=Command.MESSAGE, headers=headers, body=body)

        def message_handler(sub, frame):
            client.queue_frame(frame)

        client.subscribe('', 'auto', id, message_handler)
        # ignore subscribe frame
        client.pop_message()

        client.handle_frame(None, frame)

        self.assertEqual(frame, client.pop_message())
Esempio n. 4
0
    def test_receive_message(self):
        client = AsyncClient()
        id = 'ad052acb-a934-4e10-8ec3-00c7417ef8d1'
        headers = {
            Headers.CONTENT_LENGTH: '78',
            Headers.DESTINATION: 'jms.topic.vdsm_responses',
            Headers.CONTENT_TYPE: 'application/json',
            Headers.SUBSCRIPTION: id
        }
        body = ('{"jsonrpc": "2.0", "id": "e8a936a6-d886-4cfa-97b9-2d54209053f'
                'f", "result": []}')
        frame = Frame(command=Command.MESSAGE, headers=headers, body=body)

        def message_handler(sub, frame):
            client.queue_frame(frame)

        client.subscribe('', 'auto', id, message_handler)
        # ignore subscribe frame
        client.pop_message()

        client.handle_frame(None, frame)

        self.assertEqual(frame, client.pop_message())
Esempio n. 5
0
    def test_receive_error(self):
        client = AsyncClient()
        frame = Frame(command=Command.ERROR, body='Test error')

        with self.assertRaises(StompError):
            client.handle_frame(None, frame)
Esempio n. 6
0
    def test_receive_error(self):
        client = AsyncClient()
        frame = Frame(command=Command.ERROR, body='Test error')

        with self.assertRaises(StompError):
            client.handle_frame(None, frame)