From 2ac116e60846dc6178cbbb9aa33873abf4bd783c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Fri, 23 Dec 2016 10:08:13 +0100
Subject: [PATCH] queue_declare test

---
 coolamqp/cluster.py  |  6 +-----
 coolamqp/handler.py  |  2 +-
 tests/test_basics.py | 13 +++++++++++++
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/coolamqp/cluster.py b/coolamqp/cluster.py
index 6ebd56a..66a7e02 100644
--- a/coolamqp/cluster.py
+++ b/coolamqp/cluster.py
@@ -201,8 +201,4 @@ class Cluster(object):
         """
         self.thread.terminate()
         self.thread.join()
-
-        if self.connected:
-            self.backend.shutdown()
-            self.backend = None
-            self.connected = False
+        # thread closes the AMQP uplink for us
diff --git a/coolamqp/handler.py b/coolamqp/handler.py
index 9705407..93e2f05 100644
--- a/coolamqp/handler.py
+++ b/coolamqp/handler.py
@@ -17,7 +17,7 @@ logger = logging.getLogger(__name__)
 
 class ClusterHandlerThread(threading.Thread):
     """
-    Thread that does bookkeeping for a Cluster
+    Thread that does bookkeeping for a Cluster.
     """
     def __init__(self, cluster):
         """
diff --git a/tests/test_basics.py b/tests/test_basics.py
index 1491104..14b949b 100644
--- a/tests/test_basics.py
+++ b/tests/test_basics.py
@@ -55,6 +55,19 @@ class TestBasics(unittest.TestCase):
         self.amqp.consume(p)
         self.amqp.consume(p).result()
 
+    def test_consume_declare(self):
+        """Spawn a second connection. One declares an exclusive queue, other tries to consume from it"""
+        amqp2 = getamqp()
+
+        has_failed = {'has_failed': False}
+
+        self.amqp.declare_queue(Queue('lol', exclusive=True)).result()
+        amqp2.consume(Queue('lol', exclusive=True), on_failed=lambda e: has_failed.update({'has_failed': True})).result()
+
+        self.assertTrue(has_failed['has_failed'])
+
+        amqp2.shutdown()
+
     def test_consume_twice(self):
         """Spawn a second connection and try to consume an exclusive queue twice"""
         amqp2 = getamqp()
-- 
GitLab