コード例 #1
0
ファイル: test_backends.py プロジェクト: intellisense/Ahem
class EmailBackendTests(TestCase):

    def setUp(self):
        self.user = mommy.make('auth.User')

        self.backend = EmailBackend()
        self.notification = TestNotification()

    def test_sends_email(self):
        self.backend.send_notification(
            self.user, self.notification)

        self.assertEqual(len(mail.outbox), 1)

    def test_adds_subject_if_passed_on_context(self):
        self.backend.send_notification(
            self.user, self.notification,
            context={'subject': 'Test Subject'})

        self.assertEqual(mail.outbox[0].subject, 'Test Subject')

    def test_uses_context_from_email_if_provided(self):
        self.backend.send_notification(
            self.user, self.notification,
            context={'from_email': '*****@*****.**'})

        self.assertEqual(mail.outbox[0].from_email, '*****@*****.**')

    def test_recipient_list_is_user_email(self):
        user = self.user

        self.backend.send_notification(
            self.user, self.notification)

        self.assertEqual(mail.outbox[0].to[0], user.email)
コード例 #2
0
ファイル: test_backends.py プロジェクト: intellisense/Ahem
    def setUp(self):
        self.user = mommy.make('auth.User')

        self.backend = EmailBackend()
        self.notification = TestNotification()