diff --git a/CHANGELOG.md b/CHANGELOG.md index cea15627c5869cbb7cc4e3d401c1bdc9bb97b613..7ff17a4d93fdbefd5c45186892689f2ee0319e75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Since v1.3.2 they'll be put here and in release description. ======== * added docs regarding consume method. +* added testing topic exchanges # v1.4.1 ======= diff --git a/coolamqp/__init__.py b/coolamqp/__init__.py index 914b3b2d57bf51fe1a74a442026af1f9f873ba27..369aa3f9486ba977708f50f64d75241e7e32445d 100644 --- a/coolamqp/__init__.py +++ b/coolamqp/__init__.py @@ -1 +1 @@ -__version__ = '1.4.2a1' +__version__ = '1.4.2a2' diff --git a/coolamqp/objects.py b/coolamqp/objects.py index 57a8b0a4a774ac1799ff80d16046ae53589c9cc2..675f7416778545fa91a7f9a2900ca4e56b3c39cd 100644 --- a/coolamqp/objects.py +++ b/coolamqp/objects.py @@ -244,7 +244,8 @@ class Queue(object): :param exclusive: Is this queue exclusive? :param auto_delete: Is this queue auto_delete ? :param arguments: either a list of (bytes, values) or a dict of (str, value) to pass as an extra argument - :warn PendingDeprecationWarning: if a non-exclusive auto_delete queue is created + :warning PendingDeprecationWarning: if a non-exclusive auto_delete queue is created or some other combinations + that will be soon unavailable (eg. RabbitMQ 4.0). """ __slots__ = ('name', 'durable', 'exchange', 'auto_delete', 'exclusive', 'anonymous', 'consumer_tag', 'arguments') @@ -265,6 +266,10 @@ class Queue(object): self.auto_delete = auto_delete self.exclusive = exclusive self.arguments = argumentify(arguments) + + if self.auto_delete and self.durable: + warnings.warn('This will be removed in RabbitMQ 4.0', PendingDeprecationWarning) + if self.auto_delete and not self.exclusive: warnings.warn('This will be removed in RabbitMQ 4.0', PendingDeprecationWarning) diff --git a/tests/test_clustering/test_topic_exchanges.py b/tests/test_clustering/test_topic_exchanges.py new file mode 100644 index 0000000000000000000000000000000000000000..8959ad5980b74037867f2fffd89193d9398aa00e --- /dev/null +++ b/tests/test_clustering/test_topic_exchanges.py @@ -0,0 +1,51 @@ +import time +import os +import unittest +import logging + +import monotonic + +from coolamqp.clustering import Cluster +from coolamqp.objects import Exchange, Queue, NodeDefinition, Message + + +XCHG = Exchange('topic', type='topic', durable=True) +QUEUE = Queue(exchange=XCHG, exclusive=True, auto_delete=True) + + +NODE = NodeDefinition(os.environ.get('AMQP_HOST', '127.0.0.1'), 'guest', 'guest', heartbeat=20) +logging.basicConfig(level=logging.DEBUG) + + +class TestTopic(unittest.TestCase): + def setUp(self): + self.c = Cluster([NODE]) + self.c.start() + + def tearDown(self): + self.c.shutdown() + + + def test_bind_stuff(self): + self.c.declare(QUEUE).result() + self.c.bind(QUEUE, XCHG, routing_key='hello-world') + + did_receive = False + + def do(msg): + nonlocal did_receive + did_receive = True + msg.ack() + + cons, fut = self.c.consume(QUEUE, on_message=do, no_ack=False) + fut.result() + + self.c.publish(Message(b'good boy'), exchange=XCHG, routing_key='hello-world') + + start = monotonic.monotonic() + while not did_receive: + time.sleep(2) + if monotonic.monotonic() - start > 10: + self.fail("Message not received within 10 seconds") + + self.cons.cancel.result()