Example #1
0
    def test_simple_send_email_with_magic_builder_1(self):
        mails = MagicMailBuilder()

        email = mails.test_email2('*****@*****.**', {'name': 'foo'})
        email.send()

        model = Message.objects.get()
        self.assertEqual(email.from_email, model.from_email)
        self.assertEqual(email.to, model.to_email.split(','))
        self.assertEqual(email.subject, model.subject)
        self.assertEqual(email.body, model.body_text)
Example #2
0
    def test_simple_send_email_with_magic_builder_1(self):
        mails = MagicMailBuilder()

        email = mails.test_email2('*****@*****.**', {'name': 'foo'})
        email.send()

        model = Message.objects.get()
        self.assertEqual(email.from_email, model.from_email)
        self.assertEqual(email.to, model.to_email.split(','))
        self.assertEqual(email.subject, model.subject)
        self.assertEqual(email.body, model.body_text)
Example #3
0
    def test_simple_send_email_with_magic_builder_1(self):
        mails = MagicMailBuilder()

        email = mails.test_email2('*****@*****.**', {'name': 'foo'})
        email.send()

        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(Message.objects.count(), 1)

        self.assertEqual(email.subject, u'Subject2: foo')
        self.assertEqual(email.body, u"body\n")
        self.assertEqual(email.alternatives, [(u'<b>Body</b>\n', 'text/html')])
Example #4
0
    def test_simple_send_email_with_magic_builder_1(self):
        mails = MagicMailBuilder()

        email = mails.test_email2('*****@*****.**', {'name': 'foo'})
        email.send()

        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(Message.objects.count(), 1)

        self.assertEqual(email.subject, u'Subject2: foo')
        self.assertEqual(email.body, u"body\n")
        self.assertEqual(email.alternatives, [(u'<b>Body</b>\n', 'text/html')])
Example #5
0
    def test_simple_send_email_with_magic_builder_1_with_extra_kwargs(self):
        mails = MagicMailBuilder()

        email = mails.test_email2(
            "*****@*****.**", {"name": "foo"}, from_email="*****@*****.**")
        email.send()

        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(Message.objects.count(), 1)

        self.assertEqual(email.subject, 'Subject2: foo')
        self.assertEqual(email.body, 'body\n')
        self.assertEqual(email.alternatives, [(u'<b>Body</b>\n', 'text/html')])
Example #6
0
    def test_simple_send_email_with_magic_builder_1_with_extra_kwargs(self):
        mails = MagicMailBuilder()

        email = mails.test_email2(
            "*****@*****.**", {"name": "foo"}, from_email="*****@*****.**")
        email.send()

        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(Message.objects.count(), 1)

        self.assertEqual(email.subject, 'Subject2: foo')
        self.assertEqual(email.body, 'body\n')
        self.assertEqual(email.alternatives, [(u'<b>Body</b>\n', 'text/html')])
Example #7
0
    def test_simple_send_email_with_magic_builder_1_with_low_priority(self):
        mails = MagicMailBuilder()

        email = mails.test_email2(
            '*****@*****.**', {'name': 'foo'}, priority=10)
        email.send()

        self.assertEqual(len(mail.outbox), 0)
        self.assertEqual(Message.objects.count(), 1)

        m1 = Message.objects.get()
        self.assertEqual(m1.status, Message.STATUS_PENDING)
        self.assertEqual(m1.priority, 10)

        core._send_pending_messages()

        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(Message.objects.count(), 1)

        m2 = Message.objects.get()
        self.assertEqual(m2.status, Message.STATUS_SENT)
        self.assertEqual(m2.priority, 10)
Example #8
0
    def test_simple_send_email_with_magic_builder_1_with_low_priority(self):
        mails = MagicMailBuilder()

        email = mails.test_email2(
            '*****@*****.**', {'name': 'foo'}, priority=10)
        email.send()

        self.assertEqual(len(mail.outbox), 0)
        self.assertEqual(Message.objects.count(), 1)

        m1 = Message.objects.get()
        self.assertEqual(m1.status, Message.STATUS_PENDING)
        self.assertEqual(m1.priority, 10)

        core._send_pending_messages()

        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(Message.objects.count(), 1)

        m2 = Message.objects.get()
        self.assertEqual(m2.status, Message.STATUS_SENT)
        self.assertEqual(m2.priority, 10)