Example #1
0
    def test_email_reminder_sent_if_member_dont_confirm(self):
        remind_members_to_push_log()
        self.assertEqual(self.total_emails_sent(), 2)

        with freeze_time(str(timezone.now() + timedelta(days=1))):
            remind_members_to_push_log()
            self.assertEqual(self.total_emails_sent(), 4)
Example #2
0
    def test_no_reminder_send_if_everyone_confirmed_their_worklogs(self):
        remind_members_to_push_log()
        self.assertEqual(self.total_emails_sent(), 2)
        self.confirm_latest_worklog(self.first)
        self.confirm_latest_worklog(self.second)

        remind_members_to_push_log()
        self.assertEqual(self.total_emails_sent(), 2)
Example #3
0
    def test_worklog_created_next_month(self):
        remind_members_to_push_log()
        self.assertEqual(self.total_emails_sent(), 2)

        self.confirm_latest_worklog(self.first)
        self.confirm_latest_worklog(self.second)

        with freeze_time(str(timezone.now() + timedelta(days=30))):
            remind_members_to_push_log()
            self.assertEqual(self.total_emails_sent(), 4)
Example #4
0
    def test_calling_send_email_twice_does_not_result_in_duplication(self):
        # TODO: Compare Worklog.objects.all() before and after the second remind_members_to_push_log()

        remind_members_to_push_log()
        self.assertEqual(self.total_emails_sent(), 2)

        # The below send mail shouldn't have any effect at all
        remind_members_to_push_log()
        self.assertEqual(
            self.total_emails_sent(), 2,
            "Emails sent on repeated task execution when it shouldn't")
Example #5
0
    def test_partial_email_reminder_sent_if_member_dont_confirm(self):
        remind_members_to_push_log()

        self.confirm_latest_worklog(self.first)

        # Now, we are left with only second user as the first has confirmed
        with freeze_time(str(timezone.now() +
                             timedelta(days=1))) as fronzen_datetime:
            # After 1 day, send_email should be triggered and it should send a reminder email
            remind_members_to_push_log()
            self.assertEqual(self.total_emails_sent(), 3)

            # Winding clock forward to the next day, send_email should be triggered
            # and it should send a reminder email
            fronzen_datetime.tick(timedelta(days=1))
            remind_members_to_push_log()
            self.assertEqual(self.total_emails_sent(), 4)

            # Second user also confirms his/her worklog
            self.confirm_latest_worklog(self.second)

            # Winding clock forward to the next day, send_email should be triggered
            # but it should not send a reminder email as everyone has pushed their
            # worklogs
            fronzen_datetime.tick(timedelta(days=1))
            remind_members_to_push_log()
            self.assertEqual(self.total_emails_sent(), 4)
Example #6
0
 def test_basic_send_email(self):
     remind_members_to_push_log()
     self.assertEqual(self.total_emails_sent(), 2)