From d5f230e2463b1ced044537e6c1441b82951ab00a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Mon, 30 Sep 2024 10:38:17 +0200
Subject: [PATCH] 1.4.2

---
 CHANGELOG.md                                  |  6 ++++++
 coolamqp/__init__.py                          |  2 +-
 coolamqp/clustering/cluster.py                |  3 +++
 tests/test_clustering/test_topic_exchanges.py | 17 ++++++++++++-----
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7ff17a4..e4ce135 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,12 @@ Since v1.3.2 they'll be put here and in release description.
 # v1.4.2
 ========
 
+* fixed and unit tested the topic exchanges
+* fixed declare documentation
+
+# v1.4.2
+========
+
 * added docs regarding consume method.
 * added testing topic exchanges
 
diff --git a/coolamqp/__init__.py b/coolamqp/__init__.py
index 369aa3f..98d186b 100644
--- a/coolamqp/__init__.py
+++ b/coolamqp/__init__.py
@@ -1 +1 @@
-__version__ = '1.4.2a2'
+__version__ = '1.4.2'
diff --git a/coolamqp/clustering/cluster.py b/coolamqp/clustering/cluster.py
index 6a8432d..80e5864 100644
--- a/coolamqp/clustering/cluster.py
+++ b/coolamqp/clustering/cluster.py
@@ -121,6 +121,9 @@ class Cluster(object):
         """
         Declare a Queue/Exchange.
 
+        .. note:: Note that if your queue relates to an exchange that has not yet been declared you'll be faced with
+                  AMQP error 404: NOT_FOUND, so try to declare your exchanges before your queues.
+
         :param obj: Queue/Exchange object
         :param persistent: should it be redefined upon reconnect?
         :param span: optional parent span, if opentracing is installed
diff --git a/tests/test_clustering/test_topic_exchanges.py b/tests/test_clustering/test_topic_exchanges.py
index 8959ad5..067db55 100644
--- a/tests/test_clustering/test_topic_exchanges.py
+++ b/tests/test_clustering/test_topic_exchanges.py
@@ -9,7 +9,7 @@ from coolamqp.clustering import Cluster
 from coolamqp.objects import Exchange, Queue, NodeDefinition, Message
 
 
-XCHG = Exchange('topic', type='topic', durable=True)
+XCHG = Exchange('smok5.results', type='topic', durable=True)
 QUEUE = Queue(exchange=XCHG, exclusive=True, auto_delete=True)
 
 
@@ -23,12 +23,16 @@ class TestTopic(unittest.TestCase):
         self.c.start()
 
     def tearDown(self):
+        try:
+            self.cons.cancel().result()
+        except AttributeError:
+            pass
         self.c.shutdown()
 
-
     def test_bind_stuff(self):
+        self.c.declare(XCHG).result()
         self.c.declare(QUEUE).result()
-        self.c.bind(QUEUE, XCHG, routing_key='hello-world')
+        self.c.bind(QUEUE, XCHG, routing_key='hello-world').result()
 
         did_receive = False
 
@@ -37,7 +41,7 @@ class TestTopic(unittest.TestCase):
             did_receive = True
             msg.ack()
 
-        cons, fut = self.c.consume(QUEUE, on_message=do, no_ack=False)
+        self.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')
@@ -48,4 +52,7 @@ class TestTopic(unittest.TestCase):
             if monotonic.monotonic() - start > 10:
                 self.fail("Message not received within 10 seconds")
 
-        self.cons.cancel.result()
+        did_receive = False
+        self.c.publish(Message(b'good boy', exchange=XCHG, routing_key='helloworld'), confirm=True).result()
+        time.sleep(5)
+        self.assertFalse(did_receive)
-- 
GitLab