def test_sending_an_email(self): """Do we send emails correctly?""" # Set this value since the JSON will get stale and can't have dynamic # dates. Note that we need to get hours involved because this way we can # be sure that our donation happens in the middle of the period of time # when the alert script will check for donations. about_a_year_ago = now() - timedelta(days=354, hours=12) Donation.objects.filter(pk=1).update(date_created=about_a_year_ago) comm = Command() comm.handle() self.assertEqual(len(mail.outbox), 1) self.assertIn('you donated $1', mail.outbox[0].body) self.assertIn('you donated $1', mail.outbox[0].alternatives[0][0])
def test_sending_an_email(self) -> None: """Do we send emails correctly?""" # Set this value since the JSON will get stale and can't have dynamic # dates. Note that we need to get hours involved because this way we # can be sure that our donation happens in the middle of the period of # time when the alert script will check for donations. about_a_year_ago = now() - timedelta(days=354, hours=12) Donation.objects.filter(pk=1).update(date_created=about_a_year_ago) comm = Command() comm.handle() self.assertEqual(len(mail.outbox), 1) self.assertIn("you donated $1", mail.outbox[0].body) self.assertIn("you donated $1", mail.outbox[0].alternatives[0][0])