diff options
-rw-r--r-- | python/qpid/client.py | 3 | ||||
-rw-r--r-- | python/tests/broker.py | 6 | ||||
-rw-r--r-- | python/tests/queue.py | 51 |
3 files changed, 60 insertions, 0 deletions
diff --git a/python/qpid/client.py b/python/qpid/client.py index a8412e5519..ed7dbca5d2 100644 --- a/python/qpid/client.py +++ b/python/qpid/client.py @@ -128,6 +128,9 @@ class ClientDelegate(Delegate): def basic_deliver(self, ch, msg): self.client.queue(msg.consumer_tag).put(msg) + def channel_pong(self, ch, msg): + msg.ok() + def channel_close(self, ch, msg): ch.close(msg) diff --git a/python/tests/broker.py b/python/tests/broker.py index 2cdfd233f7..a978993891 100644 --- a/python/tests/broker.py +++ b/python/tests/broker.py @@ -108,3 +108,9 @@ class BrokerTests(TestBase): if isinstance(e.args[0], str): self.fail(e) self.assertConnectionException(504, e.args[0]) + def test_ping_pong(self): + channel = self.channel + reply = channel.channel_ping() + self.assertEqual(reply.method.klass.name, "channel") + self.assertEqual(reply.method.name, "ok") + #todo: provide a way to get notified of incoming pongs... diff --git a/python/tests/queue.py b/python/tests/queue.py index ea83ce8b39..b94b8b7739 100644 --- a/python/tests/queue.py +++ b/python/tests/queue.py @@ -150,6 +150,57 @@ class QueueTests(TestBase): except Closed, e: self.assertChannelException(404, e.args[0]) + def test_unbind_direct(self): + self.unbind_test(exchange="amq.direct", routing_key="key") + + def test_unbind_topic(self): + self.unbind_test(exchange="amq.topic", routing_key="key") + + def test_unbind_fanout(self): + self.unbind_test(exchange="amq.fanout") + + def test_unbind_headers(self): + self.unbind_test(exchange="amq.match", args={ "x-match":"all", "a":"b"}, headers={"a":"b"}) + + def unbind_test(self, exchange, routing_key="", args=None, headers={}): + #bind two queues and consume from them + channel = self.channel + + channel.queue_declare(queue="queue-1", exclusive="True") + channel.queue_declare(queue="queue-2", exclusive="True") + + channel.message_consume(queue="queue-1", destination="queue-1", no_ack=True) + channel.message_consume(queue="queue-2", destination="queue-2", no_ack=True) + + queue1 = self.client.queue("queue-1") + queue2 = self.client.queue("queue-2") + + channel.queue_bind(exchange=exchange, queue="queue-1", routing_key=routing_key, arguments=args) + channel.queue_bind(exchange=exchange, queue="queue-2", routing_key=routing_key, arguments=args) + + #send a message that will match both bindings + channel.message_transfer(destination=exchange, routing_key=routing_key, application_headers=headers, body="one") + + #unbind first queue + channel.queue_unbind(exchange=exchange, queue="queue-1", routing_key=routing_key, arguments=args) + + #send another message + channel.message_transfer(destination=exchange, routing_key=routing_key, application_headers=headers, body="two") + + #check one queue has both messages and the other has only one + self.assertEquals("one", queue1.get(timeout=1).body) + try: + msg = queue1.get(timeout=1) + self.fail("Got extra message: %s" % msg.body) + except Empty: pass + + self.assertEquals("one", queue2.get(timeout=1).body) + self.assertEquals("two", queue2.get(timeout=1).body) + try: + msg = queue2.get(timeout=1) + self.fail("Got extra message: " + msg) + except Empty: pass + def test_delete_simple(self): """ |