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/query.py | |
| 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/query.py')
| -rw-r--r-- | python/tests_0-10/query.py | 233 |
1 files changed, 118 insertions, 115 deletions
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) |
