diff --git a/coolamqp/backends/pyamqp.py b/coolamqp/backends/pyamqp.py index 12ae1a052cb27796dd9bd9ef904932501057150f..98c96249ae196ac9116fc7a080e30c8df8c2a667 100644 --- a/coolamqp/backends/pyamqp.py +++ b/coolamqp/backends/pyamqp.py @@ -74,7 +74,7 @@ class PyAMQPBackend(AMQPBackend): @translate_exceptions def basic_publish(self, message, exchange, routing_key): # convert this to pyamqp's Message - a = amqp.Message(message.body, + a = amqp.Message(six.binary_type(message.body), **message.properties) self.channel.basic_publish(a, exchange=exchange.name, routing_key=routing_key) @@ -142,7 +142,7 @@ class PyAMQPBackend(AMQPBackend): self.cluster_handler_thread._on_consumercancelled(consumer_tag) def __on_message(self, message): - self.cluster_handler_thread._on_recvmessage(message.body, + self.cluster_handler_thread._on_recvmessage(six.binary_type(message.body), message.delivery_info['exchange'], message.delivery_info['routing_key'], message.delivery_info['delivery_tag'], diff --git a/setup.py b/setup.py index 3b25fbde548e40c1513690503ff6f58fea19fb55..c87da9d80beda730f2511a32880b5ab70c2b557d 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,12 @@ from setuptools import setup setup(name='CoolAMQP', - version='0.9', + version='0.10', description='AMQP client with sane reconnects', author='DMS Serwis s.c.', author_email='piotrm@smok.co', url='https://github.com/smok-serwis/coolamqp', - download_url='https://github.com/smok-serwis/coolamqp/archive/v0.9.zip', + download_url='https://github.com/smok-serwis/coolamqp/archive/v0.10.zip', keywords=['amqp', 'pyamqp', 'rabbitmq', 'client', 'network', 'ha', 'high availability'], packages=[ 'coolamqp', diff --git a/tests/test_basics.py b/tests/test_basics.py index 712efbd42254c728cbffedf7a3a210e6b512537f..c55764cd901c617bd315859264c538a27220dcaa 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -32,11 +32,12 @@ class TestBasics(unittest.TestCase): myq = Queue('myqueue', exclusive=True) self.amqp.consume(myq) - self.amqp.send(Message('what the fuck'), '', routing_key='myqueue') + self.amqp.send(Message(b'what the fuck'), '', routing_key='myqueue') p = self.amqp.drain(wait=1) self.assertIsInstance(p, MessageReceived) - self.assertEquals(p.message.body, 'what the fuck') + self.assertEquals(p.message.body, b'what the fuck') + self.assertIsInstance(p.message.body, six.binary_type) p.message.ack() self.assertIs(self.amqp.drain(wait=1), None) @@ -45,16 +46,16 @@ class TestBasics(unittest.TestCase): myq = Queue('myqueue', exclusive=True) self.amqp.consume(myq) - self.amqp.send(Message('what the fuck'), '', routing_key='myqueue') + self.amqp.send(Message(b'what the fuck'), '', routing_key='myqueue') p = self.amqp.drain(wait=4) self.assertIsInstance(p, MessageReceived) - self.assertEquals(p.message.body, 'what the fuck') + self.assertEquals(p.message.body, b'what the fuck') p.message.nack() p = self.amqp.drain(wait=4) self.assertIsInstance(p, MessageReceived) - self.assertEquals(six.text_type(p.message.body), 'what the fuck') + self.assertEquals(six.text_type(p.message.body), b'what the fuck') def test_bug_hangs(self): p = Queue('lol', exclusive=True) @@ -78,8 +79,8 @@ class TestBasics(unittest.TestCase): self.amqp.qos(0, 1) self.amqp.consume(Queue('lol', exclusive=True)).result() - self.amqp.send(Message('what the fuck'), '', routing_key='lol') - self.amqp.send(Message('what the fuck'), '', routing_key='lol') + self.amqp.send(Message(b'what the fuck'), '', routing_key='lol') + self.amqp.send(Message(b'what the fuck'), '', routing_key='lol') p = self.amqp.drain(wait=4) self.assertIsInstance(p, MessageReceived) @@ -105,11 +106,11 @@ class TestBasics(unittest.TestCase): myq = Queue('myqueue', exclusive=True) self.amqp.consume(myq) - self.amqp.send(Message('what the fuck'), '', routing_key='myqueue') + 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, 'what the fuck') + self.assertEquals(p.message.body, b'what the fuck') def test_consumer_cancelled_on_queue_deletion(self): myq = Queue('myqueue', exclusive=True) @@ -142,7 +143,7 @@ class TestBasics(unittest.TestCase): self.amqp.consume(q1) self.amqp.consume(q2) - self.amqp.send(Message('hello'), xchg) + self.amqp.send(Message(b'hello'), xchg) self.assertIsInstance(self.amqp.drain(wait=4), MessageReceived) self.assertIsInstance(self.amqp.drain(wait=4), MessageReceived) diff --git a/tests/test_failures.py b/tests/test_failures.py index 53685a48b39f9ca6e6caf3bdb1dd1c95990f5d09..9cc2f7bd5172a2e6a22089f2987a72f53f5f2b9a 100644 --- a/tests/test_failures.py +++ b/tests/test_failures.py @@ -59,8 +59,8 @@ class TestFailures(unittest.TestCase): self.assertIsInstance(self.amqp.drain(wait=10), ConnectionUp) self.amqp.consume(Queue('lol', exclusive=True)).result() - self.amqp.send(Message('what the fuck'), '', routing_key='lol') - self.amqp.send(Message('what the fuck'), '', routing_key='lol') + self.amqp.send(Message(b'what the fuck'), '', routing_key='lol') + self.amqp.send(Message(b'what the fuck'), '', routing_key='lol') p = self.amqp.drain(wait=4) self.assertIsInstance(p, MessageReceived) @@ -104,7 +104,7 @@ class TestFailures(unittest.TestCase): self.assertIsInstance(self.amqp.drain(wait=4), ConnectionDown) self.assertIsInstance(self.amqp.drain(wait=6), ConnectionUp) - self.amqp.send(Message('what the fuck'), '', routing_key='wtf1') + self.amqp.send(Message(b'what the fuck'), '', routing_key='wtf1') self.assertIsInstance(self.amqp.drain(wait=10), MessageReceived) diff --git a/tests/test_performance.py b/tests/test_performance.py index 0cd1b7d0db83179af223550aee5cee13372e31f6..9ae570422aebbf5a3772b15501eaecf0f2ae5e2a 100644 --- a/tests/test_performance.py +++ b/tests/test_performance.py @@ -42,5 +42,5 @@ class TestBasics(unittest.TestCase): def test_sending_a_message(self): with self.takes_less_than(0.5): - self.amqp.send(Message(''), routing_key='nowhere').result() + self.amqp.send(Message(b''), routing_key='nowhere').result()