summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2007-02-09 17:51:35 +0000
committerGordon Sim <gsim@apache.org>2007-02-09 17:51:35 +0000
commit1ddbee45e8059e1eb64d94526a6abb8e396643ac (patch)
tree84dd7dace5ed686eaa5c82df34506cc7dbaa5b46
parente754770e56a9ff0df5d5be73b04ed658cdbc5855 (diff)
downloadqpid-python-1ddbee45e8059e1eb64d94526a6abb8e396643ac.tar.gz
* qpid/client.py - added channel_pong handler to delegate
* tests/broker.py - simple ping/pong test * tests/queue.py - queue_unbind tests for all standard exchanges git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@505388 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--python/qpid/client.py3
-rw-r--r--python/tests/broker.py6
-rw-r--r--python/tests/queue.py51
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):
"""