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_amq_manager.py 1.2KB

123456789101112131415161718192021222324252627282930313233343536
  1. from __future__ import absolute_import
  2. from kombu import Connection
  3. from kombu.tests.case import Case, mask_modules, module_exists, patch
  4. class test_get_manager(Case):
  5. @mask_modules('pyrabbit')
  6. def test_without_pyrabbit(self):
  7. with self.assertRaises(ImportError):
  8. Connection('amqp://').get_manager()
  9. @module_exists('pyrabbit')
  10. def test_with_pyrabbit(self):
  11. with patch('pyrabbit.Client', create=True) as Client:
  12. manager = Connection('amqp://').get_manager()
  13. self.assertIsNotNone(manager)
  14. Client.assert_called_with(
  15. 'localhost:15672', 'guest', 'guest',
  16. )
  17. @module_exists('pyrabbit')
  18. def test_transport_options(self):
  19. with patch('pyrabbit.Client', create=True) as Client:
  20. manager = Connection('amqp://', transport_options={
  21. 'manager_hostname': 'admin.mq.vandelay.com',
  22. 'manager_port': 808,
  23. 'manager_userid': 'george',
  24. 'manager_password': 'bosco',
  25. }).get_manager()
  26. self.assertIsNotNone(manager)
  27. Client.assert_called_with(
  28. 'admin.mq.vandelay.com:808', 'george', 'bosco',
  29. )