def run(self, name=None, backend=None, *args, **kwargs): """ The Celery task. Delivers the notification via all backends returned by :param:`backend`. """ assert name is not None, "No 'name' specified to notify" assert backend is not None, "No 'backend' specified to notify with" backends = backend().get_backends(*args, **kwargs) notify(name, backends=backends, *args, **kwargs)
def test_notifying_with_decorator(self): results = notify('decorator', 'Arg1', 'Arg2', kwarg1='Kwarg1', kwarg2='Kwarg2') self.assertEqual(2, len(results)) self._assert_results(results) results = decorator_notification0.notify('Arg1', 'Arg2', kwarg1='Kwarg1', kwarg2='Kwarg2') self._assert_results(results) self.assertEqual(2, len(results))
def test_notifying_with_class(self): results = notify('class', 'Arg1', 'Arg2', kwarg1='Kwarg1', kwarg2='Kwarg2') self.assertEqual(2, len(results)) self._assert_results(results)
def test_notifying_once_with_class(self): results = notify('class', 'Arg1', 'Arg2', kwarg1='Kwarg1', kwarg2='Kwarg2', backends=[ClassNotification0]) self.assertEqual(1, len(results)) self._assert_results(results)
def notify_once(*args, **kwargs): """ Sends this notification off only to the current backend. """ return notify(name, backends=[NotificationCls], *args, **kwargs)
def notify_all(*args, **kwargs): """ Sends this notification off to every backend with the configured name. """ return notify(name, *args, **kwargs)