'BlockingChannel: Test queue_bind and queue_unbind'

def test(self):

    connection = self._connect()
    ch = connection.channel()
    q_name = ('TestQueueBindAndUnbindAndPurge_q' + uuid.uuid1().hex)
    exg_name = ('TestQueueBindAndUnbindAndPurge_exg_' + uuid.uuid1().hex)
    routing_key = 'TestQueueBindAndUnbindAndPurge'
    res = ch.confirm_delivery()
    self.assertIsNone(res)
    ch.exchange_declare(exg_name, exchange_type='direct')
    self.addCleanup(connection.channel().exchange_delete, exg_name)
    ch.queue_declare(q_name, auto_delete=True)
    self.addCleanup(self._connect().channel().queue_delete, q_name)
    frame = ch.queue_bind(q_name, exchange=exg_name, routing_key=routing_key)
    self.assertIsInstance(frame.method, pika.spec.Queue.BindOk)
    frame = ch.queue_declare(q_name, passive=True)
    self.assertEqual(frame.method.message_count, 0)
    ch.publish(exg_name, routing_key, body='TestQueueBindAndUnbindAndPurge', mandatory=True)
    frame = ch.queue_declare(q_name, passive=True)
    self.assertEqual(frame.method.message_count, 1)
    frame = ch.queue_unbind(queue=q_name, exchange=exg_name, routing_key=routing_key)
    self.assertIsInstance(frame.method, pika.spec.Queue.UnbindOk)
    with self.assertRaises(pika.exceptions.UnroutableError):
        ch.publish(exg_name, routing_key, body='TestQueueBindAndUnbindAndPurge-2', mandatory=True)
    frame = ch.queue_purge(q_name)
    self.assertIsInstance(frame.method, pika.spec.Queue.PurgeOk)
    self.assertEqual(frame.method.message_count, 1)
    frame = ch.queue_declare(q_name, passive=True)
    self.assertEqual(frame.method.message_count, 0)
