From ffee30f3792120998238506da82cc279e300450c Mon Sep 17 00:00:00 2001
From: Piotr Maslanka <piotr.maslanka@henrietta.com.pl>
Date: Tue, 10 Jan 2017 15:10:26 +0100
Subject: [PATCH] tests

---
 coolamqp/attaches/consumer.py        |  1 +
 tests/test_clustering/test_a.py      | 20 ++++++++++++++++++++
 tests/test_clustering/test_double.py |  8 ++------
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/coolamqp/attaches/consumer.py b/coolamqp/attaches/consumer.py
index 354afb6..74bd4dc 100644
--- a/coolamqp/attaches/consumer.py
+++ b/coolamqp/attaches/consumer.py
@@ -113,6 +113,7 @@ class Consumer(Channeler):
         we simply trash the channel. Idk if it's a good idea...
 
         .ack() or .nack() for messages from this customer will have no effect.
+        :return: a Future to tell when it's done. The future will always succeed - sooner, or later.
         """
         self.cancelled = True
         self.method(ChannelClose(0, b'consumer cancelled', 0, 0))
diff --git a/tests/test_clustering/test_a.py b/tests/test_clustering/test_a.py
index 7e51789..8cadf4c 100644
--- a/tests/test_clustering/test_a.py
+++ b/tests/test_clustering/test_a.py
@@ -30,6 +30,21 @@ class TestA(unittest.TestCase):
         fut.result()
         con.cancel()
 
+
+    def test_set_qos_but_later(self):
+        con, fut = self.c.consume(Queue(u'hello', exclusive=True))
+
+        fut.result()
+
+        con.set_qos(100, 100)
+        time.sleep(1)
+        self.assertEquals(con.qos, (100, 100))
+
+        con.set_qos(None, 110)
+        time.sleep(1)
+        self.assertEquals(con.qos, (0, 110))
+
+
     def test_send_recv_zerolen(self):
 
         P = {'q': False}
@@ -105,3 +120,8 @@ class TestA(unittest.TestCase):
 
         self.assertTrue(P['q'])
 
+
+    def test_consumer_cancel(self):
+        con, fut = self.c.consume(Queue(u'hello', exclusive=True, auto_delete=True))
+        fut.result()
+        con.cancel().result()
\ No newline at end of file
diff --git a/tests/test_clustering/test_double.py b/tests/test_clustering/test_double.py
index 038e247..f31e275 100644
--- a/tests/test_clustering/test_double.py
+++ b/tests/test_clustering/test_double.py
@@ -9,7 +9,7 @@ import time, logging, threading
 from coolamqp.objects import Message, MessageProperties, NodeDefinition, Queue, ReceivedMessage
 from coolamqp.clustering import Cluster
 NODE = NodeDefinition('127.0.0.1', 'guest', 'guest', heartbeat=20)
-
+from coolamqp.exceptions import ResourceLocked
 
 class TestDouble(unittest.TestCase):
 
@@ -28,13 +28,9 @@ class TestDouble(unittest.TestCase):
 
         q = Queue(u'yo', exclusive=True, auto_delete=True)
 
-        con, fut = self.c1.consume(q)
+        con, fut = self.c1.consume(q, qos=(None, 20))
         fut.result()
 
         con2, fut2 = self.c2.consume(q, fail_on_first_time_resource_locked=True)
 
-        from coolamqp.exceptions import ResourceLocked
-
         self.assertRaises(ResourceLocked, lambda: fut2.result())
-
-        
-- 
GitLab