Example #1
0
    def test_it_sends_weekly_report(self):
        self.profile.reports = "weekly"
        self.profile.save()

        cmd = Command(stdout=Mock())
        cmd.pause = Mock()  # don't pause for 1s

        cmd.handle_one_report()

        email = mail.outbox[0]
        self.assertEqual(email.subject, "Weekly Report")
        self.assertIn("This is a weekly report", email.body)
        self.assertIn("This is a weekly report", email.alternatives[0][0])
Example #2
0
    def test_it_sends_monthly_report(self):
        cmd = Command(stdout=Mock())
        cmd.pause = Mock()  # don't pause for 1s

        found = cmd.handle_one_report()
        self.assertTrue(found)

        self.profile.refresh_from_db()
        self.assertTrue(self.profile.next_report_date > now())
        self.assertEqual(self.profile.next_report_date.day, 1)
        self.assertEqual(len(mail.outbox), 1)

        email = mail.outbox[0]
        self.assertTrue("List-Unsubscribe" in email.extra_headers)
        self.assertTrue("List-Unsubscribe-Post" in email.extra_headers)
        self.assertEqual(email.subject, "Monthly Report")
        self.assertIn("This is a monthly report", email.body)
        self.assertIn("This is a monthly report", email.alternatives[0][0])