Author: gsim
Date: Fri Feb 9 09:51:35 2007
New Revision: 505388
URL: http://svn.apache.org/viewvc?view=rev&rev=505388
Log:
* 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
Modified:
incubator/qpid/branches/qpid.0-9/python/qpid/client.py
incubator/qpid/branches/qpid.0-9/python/tests/broker.py
incubator/qpid/branches/qpid.0-9/python/tests/queue.py
Modified: incubator/qpid/branches/qpid.0-9/python/qpid/client.py
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/python/qpid/client.py?view=diff&rev=505388&r1=505387&r2=505388
==============================================================================
--- incubator/qpid/branches/qpid.0-9/python/qpid/client.py (original)
+++ incubator/qpid/branches/qpid.0-9/python/qpid/client.py Fri Feb 9 09:51:35
2007
@@ -128,6 +128,9 @@
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)
Modified: incubator/qpid/branches/qpid.0-9/python/tests/broker.py
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/python/tests/broker.py?view=diff&rev=505388&r1=505387&r2=505388
==============================================================================
--- incubator/qpid/branches/qpid.0-9/python/tests/broker.py (original)
+++ incubator/qpid/branches/qpid.0-9/python/tests/broker.py Fri Feb 9 09:51:35
2007
@@ -108,3 +108,9 @@
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...
Modified: incubator/qpid/branches/qpid.0-9/python/tests/queue.py
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/qpid.0-9/python/tests/queue.py?view=diff&rev=505388&r1=505387&r2=505388
==============================================================================
--- incubator/qpid/branches/qpid.0-9/python/tests/queue.py (original)
+++ incubator/qpid/branches/qpid.0-9/python/tests/queue.py Fri Feb 9 09:51:35
2007
@@ -150,6 +150,57 @@
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):
"""