예제 #1
0
    def test_it_sends_nag(self):
        cmd = Command(stdout=Mock())
        cmd.pause = Mock()  # don't pause for 1s

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

        self.profile.refresh_from_db()
        self.assertTrue(self.profile.next_nag_date > now())
        self.assertEqual(len(mail.outbox), 1)
예제 #2
0
    def test_it_sends_report(self):
        cmd = Command()
        cmd.stdout = Mock()  # silence output to stdout
        cmd.pause = Mock()  # don't pause for 1s

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

        self.profile.refresh_from_db()
        self.assertTrue(self.profile.next_report_date > now())
        self.assertEqual(len(mail.outbox), 1)
예제 #3
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])
예제 #4
0
    def test_it_sends_nag(self):
        cmd = Command(stdout=Mock())
        cmd.pause = Mock()  # don't pause for 1s

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

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

        email = mail.outbox[0]
        html = email.alternatives[0][0]
        self.assertNotIn(str(self.check.code), email.body)
        self.assertNotIn(str(self.check.code), html)
예제 #5
0
    def test_it_sends_report(self):
        cmd = Command()
        cmd.stdout = Mock()  # silence output to stdout
        cmd.pause = Mock()  # don't pause for 1s

        found = cmd.handle_one_monthly_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)
예제 #6
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])