Skip to content

Commit

Permalink
[fix] add bad handler
Browse files Browse the repository at this point in the history
  • Loading branch information
mosquito committed May 17, 2017
1 parent 35d934e commit e0a465c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_amqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,36 @@ def test_basic_return(self):

self.assertEqual(returned.body, body)

# handler with exception
f = asyncio.Future(loop=self.loop)

yield from channel.close()

channel = yield from client.channel() # type: aio_pika.Channel

def bad_handler(message):
try:
raise ValueError
finally:
f.set_result(message)

channel.add_on_return_callback(bad_handler)

body = bytes(shortuuid.uuid(), 'utf-8')

yield from channel.default_exchange.publish(
Message(
body,
content_type='text/plain',
headers={'foo': 'bar'}
),
self.get_random_name("test_basic_return")
)

returned = yield from f

self.assertEqual(returned.body, body)

yield from wait((client.close(), client.closing), loop=self.loop)


Expand Down

0 comments on commit e0a465c

Please sign in to comment.