def test_dummy(self): backend = get_backend(_backend('dummy')) self.assertIsNotNone(backend) djhipchat.sent_messages = [] djhipchat.send_message('1234', 'dummy') self.assertEqual([], djhipchat.sent_messages)
def send_message(*args, **kwargs): try: backend = get_backend(getattr(settings, 'HIPCHAT_CELERY_BACKEND')) except AttributeError: raise ImproperlyConfigured( "You need to specify HIPCHAT_CELERY_BACKEND") backend.send_message(*args, **kwargs)
def test_backend(self): backend = get_backend(_backend('celery')) self.assertIsNotNone(backend) djhipchat.sent_messages = [] djhipchat.send_message('1234', 'dummy', sender='TestFrom') expected = { 'room_id': '1234', 'message': 'dummy', 'from': 'TestFrom', 'format': 'json', 'message_format': 'html', 'notify': 0, 'color': 'yellow' } self.assertEqual([expected], djhipchat.sent_messages)
def test_locmem(self): backend = get_backend(_backend('locmem')) self.assertIsNotNone(backend) djhipchat.sent_messages = [] djhipchat.send_message('1234', 'locmem test', sender='TestFrom') # (room_id, message, sender, message_format, notify, color) expected = { 'room_id': '1234', 'message': 'locmem test', 'from': 'TestFrom', 'format': 'json', 'message_format': 'html', 'notify': 0, 'color': 'yellow' } self.assertEqual([expected], djhipchat.sent_messages)
def test_backend_errors(self): self.assertRaises(ImproperlyConfigured, lambda: get_backend('djhipchat.foo.BadModule')) self.assertRaises( ImproperlyConfigured, lambda: get_backend('djhipchat.backends.dummy.BadClass'))
def test_backend_errors(self): self.assertRaises(ImproperlyConfigured, lambda: get_backend('djhipchat.foo.BadModule')) self.assertRaises(ImproperlyConfigured, lambda: get_backend( 'djhipchat.backends.dummy.BadClass'))