'BlockingChannel.basic_publish from basic_consume callback'

def test(self):

    connection = self._connect()
    ch = connection.channel()
    src_q_name = ('TestPublishFromBasicConsumeCallback_src_q' + uuid.uuid1().hex)
    dest_q_name = ('TestPublishFromBasicConsumeCallback_dest_q' + uuid.uuid1().hex)
    ch.confirm_delivery()
    ch.queue_declare(src_q_name, auto_delete=True)
    self.addCleanup(self._connect().channel().queue_delete, src_q_name)
    ch.queue_declare(dest_q_name, auto_delete=True)
    self.addCleanup(self._connect().channel().queue_delete, dest_q_name)
    ch.publish('', routing_key=src_q_name, body='via-publish', mandatory=True)
    def on_consume(channel, method, props, body):
        channel.publish('', routing_key=dest_q_name, body=body, properties=props, mandatory=True)
        channel.basic_ack(method.delivery_tag)
    ch.basic_consume(on_consume, src_q_name, no_ack=False, exclusive=False, arguments=None)
    for (_, _, rx_body) in ch.consume(dest_q_name, no_ack=True):
        self.assertEqual(rx_body, as_bytes('via-publish'))
        break
    else:
        self.fail('failed    to    consume    a    messages    from    destination    q')
