From 7666edd8d878684dbeb0a734001343694b1dfbb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Sat, 24 Dec 2016 05:22:58 +0100 Subject: [PATCH] v0.10 fixes #5 --- coolamqp/backends/pyamqp.py | 4 ++-- setup.py | 4 ++-- tests/test_basics.py | 21 +++++++++++---------- tests/test_failures.py | 6 +++--- tests/test_performance.py | 2 +- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/coolamqp/backends/pyamqp.py b/coolamqp/backends/pyamqp.py index 12ae1a0..98c9624 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 3b25fbd..c87da9d 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 712efbd..c55764c 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 53685a4..9cc2f7b 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 0cd1b7d..9ae5704 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() -- GitLab