Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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))           
Ejemplo n.º 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)
Ejemplo n.º 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))           
Ejemplo n.º 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)
Ejemplo n.º 7
0
 def notify_once(*args, **kwargs):
     """
     Sends this notification off only to the current backend.
     """
     return notify(name, backends=[NotificationCls], *args, **kwargs)
Ejemplo n.º 8
0
 def notify_all(*args, **kwargs):
     """
     Sends this notification off to every backend with the configured name. 
     """
     return notify(name, *args, **kwargs)
Ejemplo n.º 9
0
 def notify_once(*args, **kwargs):
     """
     Sends this notification off only to the current backend.
     """
     return notify(name, backends=[NotificationCls], *args, **kwargs)
Ejemplo n.º 10
0
 def notify_all(*args, **kwargs):
     """
     Sends this notification off to every backend with the configured name.
     """
     return notify(name, *args, **kwargs)
Ejemplo n.º 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)
Ejemplo n.º 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)