diff options
| author | Gordon Sim <gsim@apache.org> | 2008-03-11 15:34:20 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2008-03-11 15:34:20 +0000 |
| commit | b32c30ec005b9e6af28785f2c924c3cb01f3c452 (patch) | |
| tree | 69f4a04a1a345758596996d96645173812423568 /python | |
| parent | 6dbea2e3b51011a28a23505145aa3a3aab6a21fa (diff) | |
| download | qpid-python-b32c30ec005b9e6af28785f2c924c3cb01f3c452.tar.gz | |
Fixed headers exchange to allow unbind using binding key and not args
Converted alternate exchange python tests
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@635976 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python')
| -rw-r--r-- | python/cpp_failing_0-10.txt | 7 | ||||
| -rw-r--r-- | python/qpid/datatypes.py | 2 | ||||
| -rw-r--r-- | python/tests_0-10/alternate_exchange.py | 137 | ||||
| -rw-r--r-- | python/tests_0-10/exchange.py | 1 | ||||
| -rw-r--r-- | python/tests_0-10/queue.py | 15 |
5 files changed, 77 insertions, 85 deletions
diff --git a/python/cpp_failing_0-10.txt b/python/cpp_failing_0-10.txt index 8b0e11b3f0..20bc77c504 100644 --- a/python/cpp_failing_0-10.txt +++ b/python/cpp_failing_0-10.txt @@ -1,15 +1,10 @@ tests.codec.FieldTableTestCase.test_field_table_decode tests.codec.FieldTableTestCase.test_field_table_multiple_name_value_pair tests.codec.FieldTableTestCase.test_field_table_name_value_pair -tests_0-10.query.QueryTests.test_exchange_bound_header tests_0-10.tx.TxTests.test_auto_rollback tests_0-10.tx.TxTests.test_commit tests_0-10.tx.TxTests.test_rollback tests_0-10.execution.ExecutionTests.test_flush -tests_0-10.alternate_exchange.AlternateExchangeTests.test_delete_while_used_by_exchange -tests_0-10.alternate_exchange.AlternateExchangeTests.test_delete_while_used_by_queue -tests_0-10.alternate_exchange.AlternateExchangeTests.test_queue_delete -tests_0-10.alternate_exchange.AlternateExchangeTests.test_unroutable tests_0-10.dtx.DtxTests.test_bad_resume tests_0-10.dtx.DtxTests.test_end tests_0-10.dtx.DtxTests.test_end_suspend_and_fail @@ -46,5 +41,3 @@ tests_0-10.testlib.TestBaseTest.testAssertEmptyPass tests_0-10.testlib.TestBaseTest.testMessageProperties tests_0-10.queue.QueueTests.test_autodelete_shared tests_0-10.queue.QueueTests.test_declare_exclusive -tests_0-10.queue.QueueTests.test_bind -tests_0-10.queue.QueueTests.test_unbind_headers diff --git a/python/qpid/datatypes.py b/python/qpid/datatypes.py index 96ef94de8a..59299b6e04 100644 --- a/python/qpid/datatypes.py +++ b/python/qpid/datatypes.py @@ -44,7 +44,7 @@ class Struct: if kwargs: unexpected = kwargs.keys()[0] - raise TypeError("%s() got an unexpected keywoard argument '%s'" % + raise TypeError("%s() got an unexpected keyword argument '%s'" % (_type.name, unexpected)) def __getitem__(self, name): diff --git a/python/tests_0-10/alternate_exchange.py b/python/tests_0-10/alternate_exchange.py index 225b3cfb69..418a8c90ee 100644 --- a/python/tests_0-10/alternate_exchange.py +++ b/python/tests_0-10/alternate_exchange.py @@ -16,12 +16,13 @@ # specific language governing permissions and limitations # under the License. # -from qpid.client import Client, Closed +import traceback from qpid.queue import Empty -from qpid.content import Content -from qpid.testlib import testrunner, TestBase +from qpid.datatypes import Message +from qpid.testlib import TestBase010 +from qpid.session import SessionException -class AlternateExchangeTests(TestBase): +class AlternateExchangeTests(TestBase010): """ Tests for the new mechanism for message returns introduced in 0-10 and available in 0-9 for preview @@ -31,36 +32,42 @@ class AlternateExchangeTests(TestBase): """ Test that unroutable messages are delivered to the alternate-exchange if specified """ - channel = self.channel + session = self.session #create an exchange with an alternate defined - channel.exchange_declare(exchange="secondary", type="fanout") - channel.exchange_declare(exchange="primary", type="direct", alternate_exchange="secondary") + session.exchange_declare(exchange="secondary", type="fanout") + session.exchange_declare(exchange="primary", type="direct", alternate_exchange="secondary") #declare, bind (to the alternate exchange) and consume from a queue for 'returned' messages - channel.queue_declare(queue="returns", exclusive=True, auto_delete=True) - channel.queue_bind(queue="returns", exchange="secondary") - self.subscribe(destination="a", queue="returns") - returned = self.client.queue("a") + session.queue_declare(queue="returns", exclusive=True, auto_delete=True) + session.exchange_bind(queue="returns", exchange="secondary") + session.message_subscribe(destination="a", queue="returns") + session.message_flow(destination="a", unit=0, value=0xFFFFFFFF) + session.message_flow(destination="a", unit=1, value=0xFFFFFFFF) + returned = session.incoming("a") #declare, bind (to the primary exchange) and consume from a queue for 'processed' messages - channel.queue_declare(queue="processed", exclusive=True, auto_delete=True) - channel.queue_bind(queue="processed", exchange="primary", routing_key="my-key") - self.subscribe(destination="b", queue="processed") - processed = self.client.queue("b") + session.queue_declare(queue="processed", exclusive=True, auto_delete=True) + session.exchange_bind(queue="processed", exchange="primary", binding_key="my-key") + session.message_subscribe(destination="b", queue="processed") + session.message_flow(destination="b", unit=0, value=0xFFFFFFFF) + session.message_flow(destination="b", unit=1, value=0xFFFFFFFF) + processed = session.incoming("b") #publish to the primary exchange #...one message that makes it to the 'processed' queue: - channel.message_transfer(destination="primary", content=Content("Good", properties={'routing_key':"my-key"})) + dp=self.session.delivery_properties(routing_key="my-key") + session.message_transfer(destination="primary", message=Message(dp, "Good")) #...and one that does not: - channel.message_transfer(destination="primary", content=Content("Bad", properties={'routing_key':"unused-key"})) + dp=self.session.delivery_properties(routing_key="unused-key") + session.message_transfer(destination="primary", message=Message(dp, "Bad")) #delete the exchanges - channel.exchange_delete(exchange="primary") - channel.exchange_delete(exchange="secondary") + session.exchange_delete(exchange="primary") + session.exchange_delete(exchange="secondary") #verify behaviour - self.assertEqual("Good", processed.get(timeout=1).content.body) - self.assertEqual("Bad", returned.get(timeout=1).content.body) + self.assertEqual("Good", processed.get(timeout=1).body) + self.assertEqual("Bad", returned.get(timeout=1).body) self.assertEmpty(processed) self.assertEmpty(returned) @@ -68,29 +75,32 @@ class AlternateExchangeTests(TestBase): """ Test that messages in a queue being deleted are delivered to the alternate-exchange if specified """ - channel = self.channel + session = self.session #set up a 'dead letter queue': - channel.exchange_declare(exchange="dlq", type="fanout") - channel.queue_declare(queue="deleted", exclusive=True, auto_delete=True) - channel.queue_bind(exchange="dlq", queue="deleted") - self.subscribe(destination="dlq", queue="deleted") - dlq = self.client.queue("dlq") + session.exchange_declare(exchange="dlq", type="fanout") + session.queue_declare(queue="deleted", exclusive=True, auto_delete=True) + session.exchange_bind(exchange="dlq", queue="deleted") + session.message_subscribe(destination="dlq", queue="deleted") + session.message_flow(destination="dlq", unit=0, value=0xFFFFFFFF) + session.message_flow(destination="dlq", unit=1, value=0xFFFFFFFF) + dlq = session.incoming("dlq") #create a queue using the dlq as its alternate exchange: - channel.queue_declare(queue="delete-me", alternate_exchange="dlq") + session.queue_declare(queue="delete-me", alternate_exchange="dlq") #send it some messages: - channel.message_transfer(content=Content("One", properties={'routing_key':"delete-me"})) - channel.message_transfer(content=Content("Two", properties={'routing_key':"delete-me"})) - channel.message_transfer(content=Content("Three", properties={'routing_key':"delete-me"})) + dp=self.session.delivery_properties(routing_key="delete-me") + session.message_transfer(message=Message(dp, "One")) + session.message_transfer(message=Message(dp, "Two")) + session.message_transfer(message=Message(dp, "Three")) #delete it: - channel.queue_delete(queue="delete-me") + session.queue_delete(queue="delete-me") #delete the dlq exchange: - channel.exchange_delete(exchange="dlq") + session.exchange_delete(exchange="dlq") #check the messages were delivered to the dlq: - self.assertEqual("One", dlq.get(timeout=1).content.body) - self.assertEqual("Two", dlq.get(timeout=1).content.body) - self.assertEqual("Three", dlq.get(timeout=1).content.body) + self.assertEqual("One", dlq.get(timeout=1).body) + self.assertEqual("Two", dlq.get(timeout=1).body) + self.assertEqual("Three", dlq.get(timeout=1).body) self.assertEmpty(dlq) def test_delete_while_used_by_queue(self): @@ -98,23 +108,19 @@ class AlternateExchangeTests(TestBase): Ensure an exchange still in use as an alternate-exchange for a queue can't be deleted """ - channel = self.channel - channel.exchange_declare(exchange="alternate", type="fanout") - channel.queue_declare(queue="q", exclusive=True, auto_delete=True, alternate_exchange="alternate") + session = self.session + session.exchange_declare(exchange="alternate", type="fanout") + + session = self.conn.session("alternate", 2) + session.queue_declare(queue="q", exclusive=True, auto_delete=True, alternate_exchange="alternate") try: - channel.exchange_delete(exchange="alternate") + session.exchange_delete(exchange="alternate") self.fail("Expected deletion of in-use alternate-exchange to fail") - except Closed, e: - #cleanup: - other = self.connect() - channel = other.channel(1) - channel.session_open() - channel.exchange_delete(exchange="alternate") - channel.session_close() - other.close() - - self.assertConnectionException(530, e.args[0]) - + except SessionException, e: + session = self.session + session.queue_delete(queue="q") + session.exchange_delete(exchange="alternate") + self.assertEquals(530, e.args[0].error_code) def test_delete_while_used_by_exchange(self): @@ -122,25 +128,19 @@ class AlternateExchangeTests(TestBase): Ensure an exchange still in use as an alternate-exchange for another exchange can't be deleted """ - channel = self.channel - channel.exchange_declare(exchange="alternate", type="fanout") - channel.exchange_declare(exchange="e", type="fanout", alternate_exchange="alternate") + session = self.session + session.exchange_declare(exchange="alternate", type="fanout") + + session = self.conn.session("alternate", 2) + session.exchange_declare(exchange="e", type="fanout", alternate_exchange="alternate") try: - channel.exchange_delete(exchange="alternate") - #cleanup: - channel.exchange_delete(exchange="e") + session.exchange_delete(exchange="alternate") self.fail("Expected deletion of in-use alternate-exchange to fail") - except Closed, e: - #cleanup: - other = self.connect() - channel = other.channel(1) - channel.session_open() - channel.exchange_delete(exchange="e") - channel.exchange_delete(exchange="alternate") - channel.session_close() - other.close() - - self.assertConnectionException(530, e.args[0]) + except SessionException, e: + session = self.session + session.exchange_delete(exchange="e") + session.exchange_delete(exchange="alternate") + self.assertEquals(530, e.args[0].error_code) def assertEmpty(self, queue): @@ -148,4 +148,3 @@ class AlternateExchangeTests(TestBase): msg = queue.get(timeout=1) self.fail("Queue not empty: " + msg) except Empty: None - diff --git a/python/tests_0-10/exchange.py b/python/tests_0-10/exchange.py index be4f72c74c..991da17ed4 100644 --- a/python/tests_0-10/exchange.py +++ b/python/tests_0-10/exchange.py @@ -45,6 +45,7 @@ class TestHelper(TestBase010): except: print "Error on tearDown:" print traceback.print_exc() + TestBase010.tearDown(self) def createMessage(self, key="", body=""): return Message(self.session.delivery_properties(routing_key=key), body) diff --git a/python/tests_0-10/queue.py b/python/tests_0-10/queue.py index bacbc60bc1..39305d4554 100644 --- a/python/tests_0-10/queue.py +++ b/python/tests_0-10/queue.py @@ -126,27 +126,26 @@ class QueueTests(TestBase010): session.queue_declare(queue="queue-1", exclusive=True, auto_delete=True) #straightforward case, both exchange & queue exist so no errors expected: - session.queue_bind(queue="queue-1", exchange="amq.direct", routing_key="key1") + session.exchange_bind(queue="queue-1", exchange="amq.direct", binding_key="key1") #use the queue name where the routing key is not specified: session.exchange_bind(queue="queue-1", exchange="amq.direct") #try and bind to non-existant exchange try: - session.queue_bind(queue="queue-1", exchange="an-invalid-exchange", routing_key="key1") + session.exchange_bind(queue="queue-1", exchange="an-invalid-exchange", binding_key="key1") self.fail("Expected bind to non-existant exchange to fail") - except Closed, e: + except SessionException, e: self.assertEquals(404, e.args[0].error_code) - #need to reopen a session: - session = self.client.session(2) - session.session_open() + def test_bind_queue_existence(self): + session = self.session #try and bind non-existant queue: try: - session.queue_bind(queue="queue-2", exchange="amq.direct", routing_key="key1") + session.exchange_bind(queue="queue-2", exchange="amq.direct", binding_key="key1") self.fail("Expected bind of non-existant queue to fail") - except Closed, e: + except SessionException, e: self.assertEquals(404, e.args[0].error_code) def test_unbind_direct(self): |
