Exemplo 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)
Exemplo 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)
Exemplo 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())
Exemplo 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())
Exemplo 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)
Exemplo 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)