Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_channel.py 1.1KB

1234567891011121314151617181920212223242526272829303132333435
  1. from __future__ import absolute_import
  2. from collections import defaultdict
  3. from amqp.channel import Channel
  4. from amqp.exceptions import NotConfirmed
  5. from amqp.serialization import AMQPWriter, AMQPReader
  6. from amqp.tests.case import Case, Mock
  7. class NoOpenChannel(Channel):
  8. def _x_open(self):
  9. pass
  10. class test_Channel(Case):
  11. def setUp(self):
  12. self.args = AMQPWriter()
  13. self.connection = Mock(name='connection')
  14. self.connection.channels = defaultdict(lambda: None)
  15. self.channel = NoOpenChannel(self.connection, channel_id=1)
  16. def test_basic_nack(self, delivery_tag=3172312312):
  17. self.args.write_longlong(delivery_tag)
  18. self.args.write_bit(0)
  19. self.args.write_bit(0)
  20. with self.assertRaises(NotConfirmed):
  21. self.channel._basic_nack(AMQPReader(self.args.getvalue()))
  22. callback = Mock(name='callback')
  23. self.channel.events['basic_nack'].add(callback)
  24. self.channel._basic_nack(AMQPReader(self.args.getvalue()))
  25. callback.assert_called_with(delivery_tag, False, False)