def test_two_owners(self): user = UserProfile.objects.exclude(pk=self.author.pk)[0] AddonUser.objects.create(user=user, addon=self.webapp) mail_pending_refunds() eq_(len(mail.outbox), 2) emails = set([m.to[0] for m in mail.outbox]) eq_(set([self.author.email, user.email]), emails)
def test_one_owner_one_other(self): user = UserProfile.objects.exclude(pk=self.author.pk)[0] AddonUser.objects.create(user=user, addon=self.webapp, role=amo.AUTHOR_ROLE_VIEWER) mail_pending_refunds() eq_(len(mail.outbox), 1) assert mail.outbox[0].to == [self.author.email]
def test_not_pending(self): for status in [ amo.REFUND_APPROVED, amo.REFUND_APPROVED_INSTANT, amo.REFUND_DECLINED ]: self.refund.update(status=status) mail_pending_refunds() eq_(len(mail.outbox), 0)
def test_two_addons(self): other = Addon.objects.create(app_slug='something-else', name='cthulhu', type=amo.ADDON_WEBAPP) AddonUser.objects.create(user=self.author, addon=other, role=amo.AUTHOR_ROLE_OWNER) self.create_refund(other) mail_pending_refunds() eq_(len(mail.outbox), 1) eq_(mail.outbox[0].body.count('1 request'), 2)
def test_email_escaping(self): self.webapp.name = 'You <3 My App' self.webapp.save() mail_pending_refunds() eq_(len(mail.outbox), 1) email = mail.outbox[0] assert str(self.webapp.name) in email.body assert '1 request' in email.body assert 'not.this.domain.com' in email.body eq_(email.to, [self.author.email])
def test_email_url(self): mail_pending_refunds() eq_(len(mail.outbox), 1) assert 'https://marketplace.mozilla.org/' in mail.outbox[0].body
def test_not_pending(self): for status in [amo.REFUND_APPROVED, amo.REFUND_APPROVED_INSTANT, amo.REFUND_DECLINED]: self.refund.update(status=status) mail_pending_refunds() eq_(len(mail.outbox), 0)
def test_none(self): self.refund.delete() mail_pending_refunds() eq_(len(mail.outbox), 0)
def test_single(self): mail_pending_refunds() eq_(len(mail.outbox), 1) assert str(self.webapp.name) in mail.outbox[0].body assert '1 request' in mail.outbox[0].body assert mail.outbox[0].to == [self.author.email]
def test_plural(self): self.create_refund() mail_pending_refunds() eq_(len(mail.outbox), 1) assert '2 requests' in mail.outbox[0].body
def test_email_url(self): mail_pending_refunds() eq_(len(mail.outbox), 1) assert 'https://some.site.com/' in mail.outbox[0].body