diff options
| author | Gordon Sim <gsim@apache.org> | 2008-03-05 19:56:43 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2008-03-05 19:56:43 +0000 |
| commit | 7e162fa97ef0d430714b9630121a055fe5adece9 (patch) | |
| tree | 3e0a99d34d9718837a44802683f7fe6f49785613 /python/tests_0-10 | |
| parent | 86779be122dea590bc1e5201c58777ea3e362a95 (diff) | |
| download | qpid-python-7e162fa97ef0d430714b9630121a055fe5adece9.tar.gz | |
forked python tests for 0-10 preview and 0-10 final
fixed result handling in c++ broker
modified testlib in python to allow new 0-10 client to be run as well
converted query tests for final 0-10
added python tests for 0-10 final to automated set for c++ broker (most unconverted still)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@634003 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/tests_0-10')
| -rw-r--r-- | python/tests_0-10/alternate_exchange.py | 28 | ||||
| -rw-r--r-- | python/tests_0-10/broker.py | 38 | ||||
| -rw-r--r-- | python/tests_0-10/query.py | 233 |
3 files changed, 137 insertions, 162 deletions
diff --git a/python/tests_0-10/alternate_exchange.py b/python/tests_0-10/alternate_exchange.py index 83f8d85811..225b3cfb69 100644 --- a/python/tests_0-10/alternate_exchange.py +++ b/python/tests_0-10/alternate_exchange.py @@ -93,34 +93,6 @@ class AlternateExchangeTests(TestBase): self.assertEqual("Three", dlq.get(timeout=1).content.body) self.assertEmpty(dlq) - - def test_immediate(self): - """ - Test that messages in a queue being deleted are delivered to the alternate-exchange if specified - """ - channel = self.channel - #set up a 'dead letter queue': - channel.exchange_declare(exchange="dlq", type="fanout") - channel.queue_declare(queue="immediate", exclusive=True, auto_delete=True) - channel.queue_bind(exchange="dlq", queue="immediate") - self.subscribe(destination="dlq", queue="immediate") - dlq = self.client.queue("dlq") - - #create a queue using the dlq as its alternate exchange: - channel.queue_declare(queue="no-consumers", alternate_exchange="dlq", exclusive=True, auto_delete=True) - #send it some messages: - #TODO: WE HAVE LOST THE IMMEDIATE FLAG; FIX THIS ONCE ITS BACK - channel.message_transfer(content=Content("no one wants me", properties={'routing_key':"no-consumers"})) - - #check the messages were delivered to the dlq: - self.assertEqual("no one wants me", dlq.get(timeout=1).content.body) - self.assertEmpty(dlq) - - #cleanup: - channel.queue_delete(queue="no-consumers") - channel.exchange_delete(exchange="dlq") - - def test_delete_while_used_by_queue(self): """ Ensure an exchange still in use as an alternate-exchange for a diff --git a/python/tests_0-10/broker.py b/python/tests_0-10/broker.py index 99936ba742..bfecb5c166 100644 --- a/python/tests_0-10/broker.py +++ b/python/tests_0-10/broker.py @@ -19,9 +19,10 @@ from qpid.client import Closed from qpid.queue import Empty from qpid.content import Content -from qpid.testlib import testrunner, TestBase +from qpid.testlib import TestBase010 +from qpid.datatypes import Message -class BrokerTests(TestBase): +class BrokerTests(TestBase010): """Tests for basic Broker functionality""" def test_ack_and_no_ack(self): @@ -57,37 +58,36 @@ class BrokerTests(TestBase): """ Test simple message delivery where consume is issued before publish """ - channel = self.channel - self.exchange_declare(channel, exchange="test-exchange", type="direct") - self.queue_declare(channel, queue="test-queue") - channel.queue_bind(queue="test-queue", exchange="test-exchange", routing_key="key") + session = self.session + session.queue_declare(queue="test-queue", exclusive=True, auto_delete=True) + session.exchange_bind(queue="test-queue", exchange="amq.fanout") consumer_tag = "tag1" - self.subscribe(queue="test-queue", destination=consumer_tag) - queue = self.client.queue(consumer_tag) + session.message_subscribe(queue="test-queue", destination=consumer_tag) + session.message_flow(unit = 0, value = 0xFFFFFFFF, destination = consumer_tag) + session.message_flow(unit = 1, value = 0xFFFFFFFF, destination = consumer_tag) + queue = session.incoming(consumer_tag) body = "Immediate Delivery" - channel.message_transfer(destination="test-exchange", content = Content(body, properties = {"routing_key" : "key"})) + session.message_transfer("amq.fanout", None, None, Message(body)) msg = queue.get(timeout=5) self.assert_(msg.content.body == body) - # TODO: Ensure we fail if immediate=True and there's no consumer. - - def test_simple_delivery_queued(self): """ Test basic message delivery where publish is issued before consume (i.e. requires queueing of the message) """ - channel = self.channel - self.exchange_declare(channel, exchange="test-exchange", type="direct") - self.queue_declare(channel, queue="test-queue") - channel.queue_bind(queue="test-queue", exchange="test-exchange", routing_key="key") + session = self.session + session.queue_declare(queue="test-queue", exclusive=True, auto_delete=True) + session.exchange_bind(queue="test-queue", exchange="amq.fanout") body = "Queued Delivery" - channel.message_transfer(destination="test-exchange", content = Content(body, properties = {"routing_key" : "key"})) + session.message_transfer("amq.fanout", None, None, Message(body)) consumer_tag = "tag1" - self.subscribe(queue="test-queue", destination=consumer_tag) - queue = self.client.queue(consumer_tag) + session.message_subscribe(queue="test-queue", destination=consumer_tag) + session.message_flow(unit = 0, value = 0xFFFFFFFF, destination = consumer_tag) + session.message_flow(unit = 1, value = 0xFFFFFFFF, destination = consumer_tag) + queue = session.incoming(consumer_tag) msg = queue.get(timeout=5) self.assert_(msg.content.body == body) diff --git a/python/tests_0-10/query.py b/python/tests_0-10/query.py index eba2ee6dd1..0bbfb079cc 100644 --- a/python/tests_0-10/query.py +++ b/python/tests_0-10/query.py @@ -19,209 +19,212 @@ from qpid.client import Client, Closed from qpid.queue import Empty from qpid.content import Content -from qpid.testlib import testrunner, TestBase +from qpid.testlib import TestBase010 -class QueryTests(TestBase): - """Tests for various query methods introduced in 0-10 and available in 0-9 for preview""" +class QueryTests(TestBase010): + """Tests for various query methods""" + + def test_queue_query(self): + session = self.session + session.queue_declare(queue="my-queue", exclusive=True) + result = session.queue_query(queue="my-queue") + self.assertEqual("my-queue", result.queue) def test_exchange_query(self): """ Test that the exchange_query method works as expected """ - channel = self.channel + session = self.session #check returned type for the standard exchanges - self.assert_type("direct", channel.exchange_query(name="amq.direct")) - self.assert_type("topic", channel.exchange_query(name="amq.topic")) - self.assert_type("fanout", channel.exchange_query(name="amq.fanout")) - self.assert_type("headers", channel.exchange_query(name="amq.match")) - self.assert_type("direct", channel.exchange_query(name="")) + self.assertEqual("direct", session.exchange_query(name="amq.direct").type) + self.assertEqual("topic", session.exchange_query(name="amq.topic").type) + self.assertEqual("fanout", session.exchange_query(name="amq.fanout").type) + self.assertEqual("headers", session.exchange_query(name="amq.match").type) + self.assertEqual("direct", session.exchange_query(name="").type) #declare an exchange - channel.exchange_declare(exchange="my-test-exchange", type= "direct", durable=False) + session.exchange_declare(exchange="my-test-exchange", type= "direct", durable=False) #check that the result of a query is as expected - response = channel.exchange_query(name="my-test-exchange") - self.assert_type("direct", response) - self.assertEqual(False, response.durable) - self.assertEqual(False, response.not_found) + response = session.exchange_query(name="my-test-exchange") + self.assertEqual("direct", response.type) + self.assert_(not response.durable) + self.assert_(not response.not_found) #delete the exchange - channel.exchange_delete(exchange="my-test-exchange") + session.exchange_delete(exchange="my-test-exchange") #check that the query now reports not-found - self.assertEqual(True, channel.exchange_query(name="my-test-exchange").not_found) - - def assert_type(self, expected_type, response): - self.assertEqual(expected_type, response.__getattr__("type")) + self.assert_(session.exchange_query(name="my-test-exchange").not_found) - def test_binding_query_direct(self): + def test_exchange_bound_direct(self): """ - Test that the binding_query method works as expected with the direct exchange + Test that the exchange_bound method works as expected with the direct exchange """ - self.binding_query_with_key("amq.direct") + self.exchange_bound_with_key("amq.direct") - def test_binding_query_topic(self): + def test_exchange_bound_topic(self): """ - Test that the binding_query method works as expected with the direct exchange + Test that the exchange_bound method works as expected with the direct exchange """ - self.binding_query_with_key("amq.topic") + self.exchange_bound_with_key("amq.topic") - def binding_query_with_key(self, exchange_name): - channel = self.channel + def exchange_bound_with_key(self, exchange_name): + session = self.session #setup: create two queues - channel.queue_declare(queue="used-queue", exclusive=True, auto_delete=True) - channel.queue_declare(queue="unused-queue", exclusive=True, auto_delete=True) + session.queue_declare(queue="used-queue", exclusive=True, auto_delete=True) + session.queue_declare(queue="unused-queue", exclusive=True, auto_delete=True) - channel.queue_bind(exchange=exchange_name, queue="used-queue", routing_key="used-key") + session.exchange_bind(exchange=exchange_name, queue="used-queue", binding_key="used-key") # test detection of any binding to specific queue - response = channel.binding_query(exchange=exchange_name, queue="used-queue") - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) - self.assertEqual(False, response.queue_not_matched) + response = session.exchange_bound(exchange=exchange_name, queue="used-queue") + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) + self.assert_(not response.queue_not_matched) # test detection of specific binding to any queue - response = channel.binding_query(exchange=exchange_name, routing_key="used-key") - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) - self.assertEqual(False, response.key_not_matched) + response = session.exchange_bound(exchange=exchange_name, binding_key="used-key") + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) + self.assert_(not response.key_not_matched) # test detection of specific binding to specific queue - response = channel.binding_query(exchange=exchange_name, queue="used-queue", routing_key="used-key") - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) - self.assertEqual(False, response.queue_not_matched) - self.assertEqual(False, response.key_not_matched) + response = session.exchange_bound(exchange=exchange_name, queue="used-queue", binding_key="used-key") + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) + self.assert_(not response.queue_not_matched) + self.assert_(not response.key_not_matched) # test unmatched queue, unspecified binding - response = channel.binding_query(exchange=exchange_name, queue="unused-queue") - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) + response = session.exchange_bound(exchange=exchange_name, queue="unused-queue") + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) self.assertEqual(True, response.queue_not_matched) # test unspecified queue, unmatched binding - response = channel.binding_query(exchange=exchange_name, routing_key="unused-key") - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) + response = session.exchange_bound(exchange=exchange_name, binding_key="unused-key") + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) self.assertEqual(True, response.key_not_matched) # test matched queue, unmatched binding - response = channel.binding_query(exchange=exchange_name, queue="used-queue", routing_key="unused-key") - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) - self.assertEqual(False, response.queue_not_matched) + response = session.exchange_bound(exchange=exchange_name, queue="used-queue", binding_key="unused-key") + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) + self.assert_(not response.queue_not_matched) self.assertEqual(True, response.key_not_matched) # test unmatched queue, matched binding - response = channel.binding_query(exchange=exchange_name, queue="unused-queue", routing_key="used-key") - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) + response = session.exchange_bound(exchange=exchange_name, queue="unused-queue", binding_key="used-key") + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) self.assertEqual(True, response.queue_not_matched) - self.assertEqual(False, response.key_not_matched) + self.assert_(not response.key_not_matched) # test unmatched queue, unmatched binding - response = channel.binding_query(exchange=exchange_name, queue="unused-queue", routing_key="unused-key") - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) + response = session.exchange_bound(exchange=exchange_name, queue="unused-queue", binding_key="unused-key") + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) self.assertEqual(True, response.queue_not_matched) self.assertEqual(True, response.key_not_matched) #test exchange not found - self.assertEqual(True, channel.binding_query(exchange="unknown-exchange").exchange_not_found) + self.assertEqual(True, session.exchange_bound(exchange="unknown-exchange").exchange_not_found) #test queue not found - self.assertEqual(True, channel.binding_query(exchange=exchange_name, queue="unknown-queue").queue_not_found) + self.assertEqual(True, session.exchange_bound(exchange=exchange_name, queue="unknown-queue").queue_not_found) - def test_binding_query_fanout(self): + def test_exchange_bound_fanout(self): """ - Test that the binding_query method works as expected with fanout exchange + Test that the exchange_bound method works as expected with fanout exchange """ - channel = self.channel + session = self.session #setup - channel.queue_declare(queue="used-queue", exclusive=True, auto_delete=True) - channel.queue_declare(queue="unused-queue", exclusive=True, auto_delete=True) - channel.queue_bind(exchange="amq.fanout", queue="used-queue") + session.queue_declare(queue="used-queue", exclusive=True, auto_delete=True) + session.queue_declare(queue="unused-queue", exclusive=True, auto_delete=True) + session.exchange_bind(exchange="amq.fanout", queue="used-queue") # test detection of any binding to specific queue - response = channel.binding_query(exchange="amq.fanout", queue="used-queue") - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) - self.assertEqual(False, response.queue_not_matched) + response = session.exchange_bound(exchange="amq.fanout", queue="used-queue") + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) + self.assert_(not response.queue_not_matched) # test unmatched queue, unspecified binding - response = channel.binding_query(exchange="amq.fanout", queue="unused-queue") - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) + response = session.exchange_bound(exchange="amq.fanout", queue="unused-queue") + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) self.assertEqual(True, response.queue_not_matched) #test exchange not found - self.assertEqual(True, channel.binding_query(exchange="unknown-exchange").exchange_not_found) + self.assertEqual(True, session.exchange_bound(exchange="unknown-exchange").exchange_not_found) #test queue not found - self.assertEqual(True, channel.binding_query(exchange="amq.fanout", queue="unknown-queue").queue_not_found) + self.assertEqual(True, session.exchange_bound(exchange="amq.fanout", queue="unknown-queue").queue_not_found) - def test_binding_query_header(self): + def test_exchange_bound_header(self): """ - Test that the binding_query method works as expected with headers exchanges + Test that the exchange_bound method works as expected with headers exchanges """ - channel = self.channel + session = self.session #setup - channel.queue_declare(queue="used-queue", exclusive=True, auto_delete=True) - channel.queue_declare(queue="unused-queue", exclusive=True, auto_delete=True) - channel.queue_bind(exchange="amq.match", queue="used-queue", arguments={"x-match":"all", "a":"A"} ) + session.queue_declare(queue="used-queue", exclusive=True, auto_delete=True) + session.queue_declare(queue="unused-queue", exclusive=True, auto_delete=True) + session.exchange_bind(exchange="amq.match", queue="used-queue", arguments={"x-match":"all", "a":"A"} ) # test detection of any binding to specific queue - response = channel.binding_query(exchange="amq.match", queue="used-queue") - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) - self.assertEqual(False, response.queue_not_matched) + response = session.exchange_bound(exchange="amq.match", queue="used-queue") + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) + self.assert_(not response.queue_not_matched) # test detection of specific binding to any queue - response = channel.binding_query(exchange="amq.match", arguments={"x-match":"all", "a":"A"}) - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) - self.assertEqual(False, response.args_not_matched) + response = session.exchange_bound(exchange="amq.match", arguments={"x-match":"all", "a":"A"}) + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) + self.assert_(not response.args_not_matched) # test detection of specific binding to specific queue - response = channel.binding_query(exchange="amq.match", queue="used-queue", arguments={"x-match":"all", "a":"A"}) - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) - self.assertEqual(False, response.queue_not_matched) - self.assertEqual(False, response.args_not_matched) + response = session.exchange_bound(exchange="amq.match", queue="used-queue", arguments={"x-match":"all", "a":"A"}) + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) + self.assert_(not response.queue_not_matched) + self.assert_(not response.args_not_matched) # test unmatched queue, unspecified binding - response = channel.binding_query(exchange="amq.match", queue="unused-queue") - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) + response = session.exchange_bound(exchange="amq.match", queue="unused-queue") + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) self.assertEqual(True, response.queue_not_matched) # test unspecified queue, unmatched binding - response = channel.binding_query(exchange="amq.match", arguments={"x-match":"all", "b":"B"}) - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) + response = session.exchange_bound(exchange="amq.match", arguments={"x-match":"all", "b":"B"}) + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) self.assertEqual(True, response.args_not_matched) # test matched queue, unmatched binding - response = channel.binding_query(exchange="amq.match", queue="used-queue", arguments={"x-match":"all", "b":"B"}) - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) - self.assertEqual(False, response.queue_not_matched) + response = session.exchange_bound(exchange="amq.match", queue="used-queue", arguments={"x-match":"all", "b":"B"}) + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) + self.assert_(not response.queue_not_matched) self.assertEqual(True, response.args_not_matched) # test unmatched queue, matched binding - response = channel.binding_query(exchange="amq.match", queue="unused-queue", arguments={"x-match":"all", "a":"A"}) - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) + response = session.exchange_bound(exchange="amq.match", queue="unused-queue", arguments={"x-match":"all", "a":"A"}) + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) self.assertEqual(True, response.queue_not_matched) - self.assertEqual(False, response.args_not_matched) + self.assert_(not response.args_not_matched) # test unmatched queue, unmatched binding - response = channel.binding_query(exchange="amq.match", queue="unused-queue", arguments={"x-match":"all", "b":"B"}) - self.assertEqual(False, response.exchange_not_found) - self.assertEqual(False, response.queue_not_found) + response = session.exchange_bound(exchange="amq.match", queue="unused-queue", arguments={"x-match":"all", "b":"B"}) + self.assert_(not response.exchange_not_found) + self.assert_(not response.queue_not_found) self.assertEqual(True, response.queue_not_matched) self.assertEqual(True, response.args_not_matched) #test exchange not found - self.assertEqual(True, channel.binding_query(exchange="unknown-exchange").exchange_not_found) + self.assertEqual(True, session.exchange_bound(exchange="unknown-exchange").exchange_not_found) #test queue not found - self.assertEqual(True, channel.binding_query(exchange="amq.match", queue="unknown-queue").queue_not_found) + self.assertEqual(True, session.exchange_bound(exchange="amq.match", queue="unknown-queue").queue_not_found) |
