Exemplo n.º 1
0
 def _send_email(self, fail_counts, disable_counts, scheduling_counts, fail_expls, owner):
     num_failures = sum(six.itervalues(fail_counts))
     num_disables = sum(six.itervalues(disable_counts))
     num_scheduling_failures = sum(six.itervalues(scheduling_counts))
     subject_parts = [
         _plural_format('{} failure{}', num_failures),
         _plural_format('{} disable{}', num_disables),
         _plural_format('{} scheduling failure{}', num_scheduling_failures),
     ]
     subject_base = ', '.join(filter(None, subject_parts))
     if subject_base:
         prefix = '' if owner in self._default_owner else 'Your tasks have '
         subject = 'Luigi: {}{} in the last {} minutes'.format(
             prefix, subject_base, self._config.email_interval)
         email_body = self._email_body(fail_counts, disable_counts, scheduling_counts, fail_expls)
         send_email(subject, email_body, email().sender, (owner,))
Exemplo n.º 2
0
 def _send_email(self, fail_counts, disable_counts, scheduling_counts, fail_expls, owner):
     num_failures = sum(six.itervalues(fail_counts))
     num_disables = sum(six.itervalues(disable_counts))
     num_scheduling_failures = sum(six.itervalues(scheduling_counts))
     subject_parts = [
         _plural_format('{} failure{}', num_failures),
         _plural_format('{} disable{}', num_disables),
         _plural_format('{} scheduling failure{}', num_scheduling_failures),
     ]
     subject_base = ', '.join(filter(None, subject_parts))
     if subject_base:
         prefix = '' if owner in self._default_owner else 'Your tasks have '
         subject = 'Luigi: {}{} in the last {} minutes'.format(
             prefix, subject_base, self._config.email_interval)
         email_body = self._email_body(fail_counts, disable_counts, scheduling_counts, fail_expls)
         send_email(subject, email_body, email().sender, (owner,))
Exemplo n.º 3
0
    def check_dispatcher(self, target):
        """
        Call notifications.send_email and test that the proper
        function was called.
        """

        expected_args = self.notification_args

        with mock.patch('luigi.notifications.{}'.format(target)) as sender:
            notifications.send_email(self.subject, self.message, self.sender,
                                     self.recipients, image_png=self.image_png)

            self.assertTrue(sender.called)

            call_args = sender.call_args[0][1:]

            self.assertEqual(tuple(expected_args), call_args)
Exemplo n.º 4
0
    def check_dispatcher(self, target):
        """
        Call notifications.send_email and test that the proper
        function was called.
        """

        expected_args = self.notification_args

        with mock.patch('luigi.notifications.{}'.format(target)) as sender:
            notifications.send_email(self.subject, self.message, self.sender,
                                     self.recipients, image_png=self.image_png)

            self.assertTrue(sender.called)

            call_args = sender.call_args[0][1:]

            self.assertEqual(tuple(expected_args), call_args)