Exemple #1
0
class TestEmailPreview(test_utils.TestCase):
    fixtures = ['base/addon_3615', 'base/users']

    def setUp(self):
        assert self.client.login(username='******',
                                 password='******')
        addon = Addon.objects.get(pk=3615)
        self.topic = EmailPreviewTopic(addon)

    def test_csv(self):
        self.topic.send_mail('the subject', u'Hello Ivan Krsti\u0107',
                             from_email='*****@*****.**',
                             recipient_list=['*****@*****.**'])
        r = self.client.get(reverse('zadmin.email_preview_csv',
                            args=[self.topic.topic]))
        eq_(r.status_code, 200)
        rdr = csv.reader(StringIO(r.content))
        eq_(rdr.next(), ['from_email', 'recipient_list', 'subject', 'body'])
        eq_(rdr.next(), ['*****@*****.**', '*****@*****.**',
                         'the subject', 'Hello Ivan Krsti\xc4\x87'])
Exemple #2
0
def admin_email(all_recipients, subject, body, preview_only=False,
                from_email=settings.DEFAULT_FROM_EMAIL,
                preview_topic='admin_email', **kw):
    log.info('[%s@%s] admin_email about %r'
             % (len(all_recipients), admin_email.rate_limit, subject))
    if preview_only:
        send = EmailPreviewTopic(topic=preview_topic).send_mail
    else:
        send = send_mail
    for recipient in all_recipients:
        send(subject, body, recipient_list=[recipient], from_email=from_email)
Exemple #3
0
class TestEmailPreview(amo.tests.TestCase):
    fixtures = ['base/addon_3615', 'base/users']

    def setUp(self):
        assert self.client.login(username='******',
                                 password='******')
        addon = Addon.objects.get(pk=3615)
        self.topic = EmailPreviewTopic(addon)

    def test_csv(self):
        self.topic.send_mail('the subject', u'Hello Ivan Krsti\u0107',
                             from_email='*****@*****.**',
                             recipient_list=['*****@*****.**'])
        r = self.client.get(reverse('zadmin.email_preview_csv',
                            args=[self.topic.topic]))
        eq_(r.status_code, 200)
        rdr = csv.reader(StringIO(r.content))
        eq_(rdr.next(), ['from_email', 'recipient_list', 'subject', 'body'])
        eq_(rdr.next(), ['*****@*****.**', '*****@*****.**',
                         'the subject', 'Hello Ivan Krsti\xc4\x87'])
Exemple #4
0
 def setUp(self):
     assert self.client.login(username='******',
                              password='******')
     addon = Addon.objects.get(pk=3615)
     self.topic = EmailPreviewTopic(addon)
Exemple #5
0
 def test_preview(self):
     res = self.post(preview_only=True)
     self.assertNoFormErrors(res)
     preview = EmailPreviewTopic(topic='email-devs')
     eq_([e.recipient_list for e in preview.filter()], ['*****@*****.**'])
     eq_(len(mail.outbox), 0)
 def setUp(self):
     assert self.client.login(username='******',
                              password='******')
     addon = Addon.objects.get(pk=3615)
     self.topic = EmailPreviewTopic(addon)
Exemple #7
0
 def test_preview(self):
     res = self.post(preview_only=True)
     self.assertNoFormErrors(res)
     preview = EmailPreviewTopic(topic='email-devs')
     eq_([e.recipient_list for e in preview.filter()], ['*****@*****.**'])
     eq_(len(mail.outbox), 0)