diff --git a/coolamqp/handler.py b/coolamqp/handler.py index 7b07bff0787e769fb485784934cdfe0d5bebc257..58a861023f93f996c2773cd827ecd54e63761e11 100644 --- a/coolamqp/handler.py +++ b/coolamqp/handler.py @@ -1,6 +1,7 @@ #coding=UTF-8 import threading import six.moves.queue as Queue +import six import logging import collections import time @@ -47,7 +48,7 @@ class ClusterHandlerThread(threading.Thread): self.backend = None self.connect_id += 1 - node = self.cluster.node_to_connect_to.next() + node = six.next(self.cluster.node_to_connect_to) logger.info('Connecting to %s', node) try: diff --git a/tests/test_cluster.py b/tests/test_cluster.py index 3b933543f64c7b296f9420d6315fa900c73bdd1a..a9ee173e873fdaea86fcf10ed2d81f58b08f62c3 100644 --- a/tests/test_cluster.py +++ b/tests/test_cluster.py @@ -15,6 +15,24 @@ class MyTestCase(unittest.TestCase): def tearDown(self): self.amqp.shutdown() + def test_nacknowledge(self): + myq = Queue('myqueue', exclusive=True) + + self.amqp.consume(myq) + self.amqp.send(Message(b'what the fuck'), '', routing_key='myqueue') + + p = self.amqp.drain(wait=10) + self.assertIsInstance(p, MessageReceived) + self.assertEquals(p.message.body, b'what the fuck') + p.message.nack() + + p = self.amqp.drain(wait=10) + self.assertIsInstance(p, MessageReceived) + self.assertEquals(p.message.body, b'what the fuck') + + self.amqp.delete_queue(myq) + + def test_send_and_receive(self): myq = Queue('myqueue', exclusive=True)