summaryrefslogtreecommitdiff
path: root/qpid/python
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2006-10-11 08:24:42 +0000
committerGordon Sim <gsim@apache.org>2006-10-11 08:24:42 +0000
commitdeff1e751c9d0c1baec2d0b7a9e5b88d5668a861 (patch)
treeaa158805ed0f59256228e10e23da780a2057fe10 /qpid/python
parent2da7f5de1cd0fe638538d11e953bb458852da345 (diff)
downloadqpid-python-deff1e751c9d0c1baec2d0b7a9e5b88d5668a861.tar.gz
Implementation of basic_get.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@462729 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
-rw-r--r--qpid/python/tests/basic.py61
-rw-r--r--qpid/python/tests/broker.py2
2 files changed, 61 insertions, 2 deletions
diff --git a/qpid/python/tests/basic.py b/qpid/python/tests/basic.py
index 50004614eb..afdf1a4003 100644
--- a/qpid/python/tests/basic.py
+++ b/qpid/python/tests/basic.py
@@ -329,3 +329,64 @@ class BasicTests(TestBase):
channel.basic_publish(routing_key="test-prefetch-size", content=Content(large))
msg = queue.get(timeout=1)
self.assertEqual(large, msg.content.body)
+
+ def test_get(self):
+ """
+ Test basic_get method
+ """
+ channel = self.channel
+ channel.queue_declare(queue="test-get", exclusive=True)
+
+ #publish some messages (no_ack=True)
+ for i in range(1, 11):
+ channel.basic_publish(routing_key="test-get", content=Content("Message %d" % i))
+
+ #use basic_get to read back the messages, and check that we get an empty at the end
+ for i in range(1, 11):
+ reply = channel.basic_get(no_ack=True)
+ self.assertEqual(reply.method.klass.name, "basic")
+ self.assertEqual(reply.method.name, "get-ok")
+ self.assertEqual("Message %d" % i, reply.content.body)
+
+ reply = channel.basic_get(no_ack=True)
+ self.assertEqual(reply.method.klass.name, "basic")
+ self.assertEqual(reply.method.name, "get-empty")
+
+ #repeat for no_ack=False
+ for i in range(11, 21):
+ channel.basic_publish(routing_key="test-get", content=Content("Message %d" % i))
+
+ for i in range(11, 21):
+ reply = channel.basic_get(no_ack=False)
+ self.assertEqual(reply.method.klass.name, "basic")
+ self.assertEqual(reply.method.name, "get-ok")
+ self.assertEqual("Message %d" % i, reply.content.body)
+ if(i == 13):
+ channel.basic_ack(delivery_tag=reply.delivery_tag, multiple=True)
+ if(i in [15, 17, 19]):
+ channel.basic_ack(delivery_tag=reply.delivery_tag)
+
+ reply = channel.basic_get(no_ack=True)
+ self.assertEqual(reply.method.klass.name, "basic")
+ self.assertEqual(reply.method.name, "get-empty")
+
+ #recover(requeue=True)
+ channel.basic_recover(requeue=True)
+
+ #get the unacked messages again (14, 16, 18, 20)
+ for i in [14, 16, 18, 20]:
+ reply = channel.basic_get(no_ack=False)
+ self.assertEqual(reply.method.klass.name, "basic")
+ self.assertEqual(reply.method.name, "get-ok")
+ self.assertEqual("Message %d" % i, reply.content.body)
+ channel.basic_ack(delivery_tag=reply.delivery_tag)
+
+ reply = channel.basic_get(no_ack=True)
+ self.assertEqual(reply.method.klass.name, "basic")
+ self.assertEqual(reply.method.name, "get-empty")
+
+ channel.basic_recover(requeue=True)
+
+ reply = channel.basic_get(no_ack=True)
+ self.assertEqual(reply.method.klass.name, "basic")
+ self.assertEqual(reply.method.name, "get-empty")
diff --git a/qpid/python/tests/broker.py b/qpid/python/tests/broker.py
index f7cb3bcef3..173391c91b 100644
--- a/qpid/python/tests/broker.py
+++ b/qpid/python/tests/broker.py
@@ -45,8 +45,6 @@ class BrokerTests(TestBase):
msg = self.client.queue(ctag).get(timeout = 5)
ch.basic_ack(delivery_tag = msg.delivery_tag)
self.assert_(msg.content.body == body)
-
- # TODO: Ensure we get a failure if an ack consumer doesn't ack.
def test_basic_delivery_immediate(self):
"""