Skip to content

Commit

Permalink
Merge pull request #3 from sprockets/fix-binary-message-publishing
Browse files Browse the repository at this point in the history
Fix binary message publishing
  • Loading branch information
chrismcguire committed Sep 25, 2015
2 parents 0c7567d + 1336a67 commit 0e01729
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
16 changes: 13 additions & 3 deletions docs/history.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
Version History
===============

`0.0.1`_ Sept 08, 2015
---------------------
`0.1.2`_ Sept 25, 2015
----------------------
- Don't log the message body

`0.1.1`_ Sept 24, 2015
----------------------
- Clean up installation and testing environment

`0.1.0`_ Sept 23, 2015
----------------------
- Initial implementation

.. _0.0.1: https://github.com/sprockets/sprockets.amqp/compare/0.0.0...0.0.1
.. _0.1.2: https://github.com/sprockets/sprockets.amqp/compare/0.1.1...0.1.2
.. _0.1.1: https://github.com/sprockets/sprockets.amqp/compare/0.1.0...0.1.1
.. _0.1.0: https://github.com/sprockets/sprockets.amqp/compare/551982c...0.1.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setuptools.setup(
name='sprockets.mixins.amqp',
version='0.1.1',
version='0.1.2',
description='Mixin for publishing events to RabbitMQ',
long_description=open('README.rst').read(),
url='https://github.com/sprockets/sprockets.mixins.amqp',
Expand Down
6 changes: 3 additions & 3 deletions sprockets/mixins/amqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from tornado import locks
from tornado import web

version_info = (0, 1, 1)
version_info = (0, 1, 2)
__version__ = '.'.join(str(v) for v in version_info)

LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -126,8 +126,8 @@ def publish(self, exchange, routing_key, message, properties):
"""
if not self._connection_ready:
yield self.maybe_connect()
LOGGER.debug('Publishing to %s->%s %r (Properties %r)', message,
exchange, routing_key, properties)
LOGGER.debug('Publishing to %d bytes->%s %r (Properties %r)',
len(message), exchange, routing_key, properties)
self.channel.basic_publish(exchange, routing_key, message,
pika.BasicProperties(**properties))

Expand Down
12 changes: 10 additions & 2 deletions tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import os
import random
import uuid

from pika import spec
Expand All @@ -9,6 +11,7 @@

from sprockets.mixins import amqp


LOGGER = logging.getLogger(__name__)


Expand All @@ -17,6 +20,11 @@ class BaseTestCase(testing.AsyncTestCase):
@gen.coroutine
def setUp(self):
super(BaseTestCase, self).setUp()

# make sure that our logging statements get executed
amqp.LOGGER.enabled = True
amqp.LOGGER.setLevel(logging.DEBUG)

self.amqp = amqp.AMQP()
self.exchange = str(uuid.uuid4())
self.queue = str(uuid.uuid4())
Expand Down Expand Up @@ -76,9 +84,9 @@ class AMQPIntegrationTests(BaseTestCase):
def publishing_tests(self):
yield self.ready.wait()
LOGGER.info('Should be ready')
message = uuid.uuid4().hex.encode('latin-1')
message = bytes(bytearray(range(255, 0, -1)))
yield self.amqp.publish(self.exchange, self.routing_key, message,
{'content_type': 'text/plain'})
{'content_type': 'application/octet-stream'})
LOGGER.info('Published')
result = yield self.get_message()
self.assertEqual(message, result[2])

0 comments on commit 0e01729

Please sign in to comment.