Exemplo n.º 1
0
    def test_basic_publish_confirms_nack(self):
        message = str(uuid.uuid4())

        def on_publish_return_nack(*_):
            channel.rpc.on_frame(spec_basic.Nack())

        connection = FakeConnection(on_write=on_publish_return_nack)
        channel = Channel(9, connection, 1)
        channel.confirming_deliveries = True
        channel.set_state(Channel.OPEN)
        basic = Basic(channel)

        self.assertFalse(basic.publish(body=message, routing_key='unittest'))
Exemplo n.º 2
0
    def test_basic_publish_confirms_raises_on_timeout(self):
        message = str(uuid.uuid4())

        connection = FakeConnection()
        channel = Channel(9, connection, 0.01)
        channel.confirming_deliveries = True
        channel.set_state(Channel.OPEN)
        basic = Basic(channel)

        self.assertRaisesRegexp(exception.AMQPChannelError,
                                "rpc requests",
                                basic.publish,
                                body=message,
                                routing_key='unittest')
Exemplo n.º 3
0
    def test_basic_publish_confirms_raises_on_invalid_frame(self):
        message = str(uuid.uuid4())

        def on_publish_return_invalid_frame(*_):
            channel.rpc.on_frame(spec_basic.Cancel())

        connection = FakeConnection(on_write=on_publish_return_invalid_frame)
        channel = Channel(9, connection, 0.01)
        channel.confirming_deliveries = True
        channel.set_state(Channel.OPEN)
        basic = Basic(channel)

        self.assertRaisesRegexp(exception.AMQPChannelError,
                                "rpc requests",
                                basic.publish,
                                body=message,
                                routing_key='unittest')