def test_after_last_payment_no_match(self, date): _make_mailing( subject=u'foo', groups=[self.group], trigger=MailingTriggers.after_last_payment.name, days=3, ) self.user.last_payment = datetime.datetime(2014, 1, 1, 0, 0, 0) date.today.return_value = datetime.date(2014, 1, 3) transaction.commit() send_mailings() self.assertEqual(len(self.mailer.outbox), 0)
def test_before_valid_to_no_match(self, date): _make_mailing( subject=u'foo', groups=[self.group], trigger=MailingTriggers.before_valid_to.name, days=3, ) self.user.valid_to = datetime.datetime(2014, 1, 1, 0, 0, 0) date.today.return_value = datetime.date(2013, 12, 30) transaction.commit() send_mailings() self.assertEqual(len(self.mailer.outbox), 0)
def test_after_create_match(self, date): _make_mailing( subject=u'foo', groups=[self.group], trigger=MailingTriggers.after_created.name, days=3, ) self.user.created = datetime.datetime(2014, 1, 1, 0, 0, 0) date.today.return_value = datetime.date(2014, 1, 4) transaction.commit() send_mailings() self.assertEqual(len(self.mailer.outbox), 1) self.assertEqual(self.mailer.outbox[0].subject, 'foo')
def test_never(self): _make_mailing(trigger=MailingTriggers.never.name) transaction.commit() send_mailings() self.assertEqual(len(self.mailer.outbox), 0)
def test_no_mailings(self): send_mailings() self.assertEqual(len(self.mailer.outbox), 0)