Esempio n. 1
0
 def test_amqp_factory_create_client(self):
     '''The amqp factory should create an amqp client with the given
     parameters and of type JunebugAMQClient'''
     factory = AmqpFactory('amqp-spec-0-8.xml', {
         'vhost': '/'}, None, None)
     client = factory.buildProtocol('localhost')
     self.assertTrue(isinstance(client, JunebugAMQClient))
     self.assertEqual(client.vhost, '/')
Esempio n. 2
0
    def test_amqp_client_publish_message_defaults(self):
        '''The amqp client should call basic_publish on the channel with
        the proper message details'''
        factory = AmqpFactory('amqp-spec-0-8.xml', {
            'vhost': '/'}, None, None)
        client = factory.buildProtocol('localhost')
        client.cached_channel = FakeChannel()
        msg = TransportUserMessage.send(
            to_addr='+1234', content='test', transport_name='testtransport')
        client.publish_message(msg)

        [amq_msg] = client.cached_channel.messages
        self.assertEqual(amq_msg['content']['delivery mode'], 2)
        self.assertEqual(amq_msg['exchange'], 'vumi')
        self.assertEqual(amq_msg['routing_key'], 'routing_key')

        vumi_msg = json.loads(amq_msg['content'].body)
        self.assertEqual(vumi_msg['message_id'], msg['message_id'])