Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
    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))           
Beispiel #4
0
 def test_notifying_with_class(self):
     results = notify('class',
                      'Arg1',
                      'Arg2',
                      kwarg1='Kwarg1',
                      kwarg2='Kwarg2')
     self.assertEqual(2, len(results))
     self._assert_results(results)
Beispiel #5
0
    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))           
Beispiel #6
0
 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)
Beispiel #7
0
 def notify_once(*args, **kwargs):
     """
     Sends this notification off only to the current backend.
     """
     return notify(name, backends=[NotificationCls], *args, **kwargs)
Beispiel #8
0
 def notify_all(*args, **kwargs):
     """
     Sends this notification off to every backend with the configured name. 
     """
     return notify(name, *args, **kwargs)
Beispiel #9
0
 def notify_once(*args, **kwargs):
     """
     Sends this notification off only to the current backend.
     """
     return notify(name, backends=[NotificationCls], *args, **kwargs)
Beispiel #10
0
 def notify_all(*args, **kwargs):
     """
     Sends this notification off to every backend with the configured name.
     """
     return notify(name, *args, **kwargs)
Beispiel #11
0
 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)
Beispiel #12
0
 def test_notifying_with_class(self):
     results = notify('class', 'Arg1', 'Arg2', kwarg1='Kwarg1', kwarg2='Kwarg2')
     self.assertEqual(2, len(results))           
     self._assert_results(results)