Exemplo n.º 1
0
    def test_answer_welcome_email(self):
        u1 = profile().user
        u2 = profile(first_answer_email_sent=True).user
        u3 = profile().user

        two_days = datetime.now() - timedelta(hours=48)

        q = question(creator=u1, save=True)
        answer(question=q, creator=u1, created=two_days, save=True)
        answer(question=q, creator=u2, created=two_days, save=True)
        answer(question=q, creator=u3, created=two_days, save=True)

        # Clear out the notifications that were sent
        mail.outbox = []
        # Send email(s) for welcome messages
        cron.send_welcome_emails()

        # There should be an email for u3 only.
        # u1 was the asker, and so did not make a contribution.
        # u2 has already recieved the email

        eq_(len(mail.outbox), 1)
        attrs_eq(mail.outbox[0], to=[u3.email])

        # u3's flag should now be set.
        u3 = User.objects.get(id=u3.id)
        eq_(u3.profile.first_answer_email_sent, True)
Exemplo n.º 2
0
    def test_l10n_welcome_email(self, get_current):
        get_current.return_value.domain = 'testserver'

        u1 = profile().user
        u2 = profile(first_l10n_email_sent=True).user

        two_days = datetime.now() - timedelta(hours=48)

        d = document(locale='ru', save=True)
        revision(document=d, creator=u1, created=two_days, save=True)
        revision(document=d, creator=u2, created=two_days, save=True)

        # Clear out the notifications that were sent
        mail.outbox = []
        # Send email(s) for welcome messages
        cron.send_welcome_emails()

        # There should be an email for u1 only.
        # u2 has already recieved the email

        eq_(len(mail.outbox), 1)
        attrs_eq(mail.outbox[0], to=[u1.email])

        # Links should be locale-neutral
        assert 'en-US' not in mail.outbox[0].body

        # Check that no links used the wrong host.
        assert 'support.mozilla.org' not in mail.outbox[0].body
        # Check that one link used the right host.
        assert 'https://testserver/kb/locales' in mail.outbox[0].body
        # Assumption: links will be done consistently, and so this is enough testing.

        # u3's flag should now be set.
        u1 = User.objects.get(id=u1.id)
        eq_(u1.profile.first_l10n_email_sent, True)
Exemplo n.º 3
0
    def test_l10n_welcome_email(self, get_current):
        get_current.return_value.domain = 'testserver'

        u1 = UserFactory()
        u2 = UserFactory(profile__first_l10n_email_sent=True)

        two_days = datetime.now() - timedelta(hours=48)

        d = DocumentFactory(locale='ru')
        RevisionFactory(document=d, creator=u1, created=two_days)
        RevisionFactory(document=d, creator=u2, created=two_days)

        # Clear out the notifications that were sent
        mail.outbox = []
        # Send email(s) for welcome messages
        cron.send_welcome_emails()

        # There should be an email for u1 only.
        # u2 has already recieved the email

        eq_(len(mail.outbox), 1)
        attrs_eq(mail.outbox[0], to=[u1.email])

        # Links should be locale-neutral
        assert 'en-US' not in mail.outbox[0].body

        # Check that no links used the wrong host.
        assert 'support.mozilla.org' not in mail.outbox[0].body
        # Check that one link used the right host.
        assert 'https://testserver/kb/locales' in mail.outbox[0].body
        # Assumption: links will be done consistently, and so this is enough testing.

        # u3's flag should now be set.
        u1 = User.objects.get(id=u1.id)
        eq_(u1.profile.first_l10n_email_sent, True)
Exemplo n.º 4
0
    def test_answer_welcome_email(self, get_current):
        get_current.return_value.domain = 'testserver'

        u1 = profile().user
        u2 = profile(first_answer_email_sent=True).user
        u3 = profile().user

        two_days = datetime.now() - timedelta(hours=48)

        q = question(creator=u1, save=True)
        answer(question=q, creator=u1, created=two_days, save=True)
        answer(question=q, creator=u2, created=two_days, save=True)
        answer(question=q, creator=u3, created=two_days, save=True)

        # Clear out the notifications that were sent
        mail.outbox = []
        # Send email(s) for welcome messages
        cron.send_welcome_emails()

        # There should be an email for u3 only.
        # u1 was the asker, and so did not make a contribution.
        # u2 has already recieved the email

        eq_(len(mail.outbox), 1)
        attrs_eq(mail.outbox[0], to=[u3.email])

        # Links should be locale-neutral
        assert 'en-US' not in mail.outbox[0].body

        # Check that no links used the wrong host.
        assert 'support.mozilla.org' not in mail.outbox[0].body
        # Check that one link used the right host.
        assert 'https://testserver/forums/contributors' in mail.outbox[0].body
        assert (
            'The community forum is at https://testserver/forums/contributors .'
            in mail.outbox[0].body)
        # Assumption: links will be done consistently, and so this is enough testing.

        # u3's flag should now be set.
        u3 = User.objects.get(id=u3.id)
        eq_(u3.profile.first_answer_email_sent, True)
Exemplo n.º 5
0
    def test_answer_welcome_email(self, get_current):
        get_current.return_value.domain = 'testserver'

        u1 = UserFactory()
        u2 = UserFactory(profile__first_answer_email_sent=True)
        u3 = UserFactory()

        two_days = datetime.now() - timedelta(hours=48)

        q = QuestionFactory(creator=u1)
        AnswerFactory(question=q, creator=u1, created=two_days)
        AnswerFactory(question=q, creator=u2, created=two_days)
        AnswerFactory(question=q, creator=u3, created=two_days)

        # Clear out the notifications that were sent
        mail.outbox = []
        # Send email(s) for welcome messages
        cron.send_welcome_emails()

        # There should be an email for u3 only.
        # u1 was the asker, and so did not make a contribution.
        # u2 has already recieved the email

        eq_(len(mail.outbox), 1)
        attrs_eq(mail.outbox[0], to=[u3.email])

        # Links should be locale-neutral
        assert 'en-US' not in mail.outbox[0].body

        # Check that no links used the wrong host.
        assert 'support.mozilla.org' not in mail.outbox[0].body
        # Check that one link used the right host.
        assert 'https://testserver/forums/contributors' in mail.outbox[0].body
        assert ('The community forum is at https://testserver/forums/contributors .'
                in mail.outbox[0].body)
        # Assumption: links will be done consistently, and so this is enough testing.

        # u3's flag should now be set.
        u3 = User.objects.get(id=u3.id)
        eq_(u3.profile.first_answer_email_sent, True)
Exemplo n.º 6
0
    def test_l10n_welcome_email(self):
        u1 = profile().user
        u2 = profile(first_l10n_email_sent=True).user

        two_days = datetime.now() - timedelta(hours=48)

        d = document(locale='ru', save=True)
        revision(document=d, creator=u1, created=two_days, save=True)
        revision(document=d, creator=u2, created=two_days, save=True)

        # Clear out the notifications that were sent
        mail.outbox = []
        # Send email(s) for welcome messages
        cron.send_welcome_emails()

        # There should be an email for u1 only.
        # u2 has already recieved the email

        eq_(len(mail.outbox), 1)
        attrs_eq(mail.outbox[0], to=[u1.email])

        # u3's flag should now be set.
        u1 = User.objects.get(id=u1.id)
        eq_(u1.profile.first_l10n_email_sent, True)