Ejemplo n.º 1
0
 def test_error_mail_disabled(self):
     task = Mock()
     x = ErrorMail(task)
     x.should_send = Mock()
     x.should_send.return_value = False
     x.send(Mock(), Mock())
     self.assertFalse(task.app.mail_admins.called)
Ejemplo n.º 2
0
class test_ErrorMail(Case):

    def setUp(self):
        self.task = Mock(name='task')
        self.mailer = ErrorMail(
            self.task, subject='foo{foo} ', body='bar{bar} ',
        )

    def test_should_send(self):
        self.assertTrue(self.mailer.should_send(Mock(), Mock()))

    def test_format_subject(self):
        self.assertEqual(
            self.mailer.format_subject({'foo': 'FOO'}),
            'fooFOO',
        )

    def test_format_body(self):
        self.assertEqual(
            self.mailer.format_body({'bar': 'BAR'}),
            'barBAR',
        )

    def test_send(self):
        self.mailer.send({'foo': 'FOO', 'bar': 'BAR'}, KeyError())
        self.task.app.mail_admins.assert_called_with(
            'fooFOO', 'barBAR', fail_silently=True,
        )
Ejemplo n.º 3
0
class test_ErrorMail(Case):
    def setUp(self):
        self.task = Mock(name='task')
        self.mailer = ErrorMail(
            self.task,
            subject='foo{foo} ',
            body='bar{bar} ',
        )

    def test_should_send(self):
        self.assertTrue(self.mailer.should_send(Mock(), Mock()))

    def test_format_subject(self):
        self.assertEqual(
            self.mailer.format_subject({'foo': 'FOO'}),
            'fooFOO',
        )

    def test_format_body(self):
        self.assertEqual(
            self.mailer.format_body({'bar': 'BAR'}),
            'barBAR',
        )

    def test_send(self):
        self.mailer.send({'foo': 'FOO', 'bar': 'BAR'}, KeyError())
        self.task.app.mail_admins.assert_called_with(
            'fooFOO',
            'barBAR',
            fail_silently=True,
        )
Ejemplo n.º 4
0
 def test_error_mail_disabled(self):
     task = Mock()
     x = ErrorMail(task)
     x.should_send = Mock()
     x.should_send.return_value = False
     x.send(Mock(), Mock())
     self.assertFalse(task.app.mail_admins.called)