

def test_ok(self):
    self.assertEqual(self.handler.get_reminder(self.case), None)
    CaseReminderHandler.now = datetime(year=2012, month=1, day=1, hour=4, minute=0)
    set_case_property_directly(self.case, 'start_sending', 'ok')
    self.case.save()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=2, hour=10, minute=0))
    self.assertEqual(reminder.start_date, date(year=2012, month=1, day=1))
    self.assertEqual(reminder.schedule_iteration_num, 1)
    self.assertEqual(reminder.current_event_sequence_num, 0)
    self.assertEqual(reminder.last_fired, None)
    CaseReminderHandler.now = datetime(year=2012, month=1, day=2, hour=9, minute=45)
    CaseReminderHandler.fire_reminders()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=2, hour=10, minute=0))
    self.assertEqual(reminder.schedule_iteration_num, 1)
    self.assertEqual(reminder.current_event_sequence_num, 0)
    self.assertEqual(reminder.last_fired, None)
    CaseReminderHandler.now = datetime(year=2012, month=1, day=2, hour=10, minute=7)
    CaseReminderHandler.fire_reminders()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=5, hour=11, minute=0))
    self.assertEqual(reminder.schedule_iteration_num, 1)
    self.assertEqual(reminder.current_event_sequence_num, 1)
    self.assertEqual(reminder.last_fired, CaseReminderHandler.now)
    CaseReminderHandler.now = datetime(year=2012, month=1, day=5, hour=11, minute=3)
    CaseReminderHandler.fire_reminders()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=5, hour=11, minute=30))
    self.assertEqual(reminder.schedule_iteration_num, 1)
    self.assertEqual(reminder.current_event_sequence_num, 2)
    self.assertEqual(reminder.last_fired, CaseReminderHandler.now)
    CaseReminderHandler.now = datetime(year=2012, month=1, day=5, hour=11, minute=30)
    CaseReminderHandler.fire_reminders()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=9, hour=10, minute=0))
    self.assertEqual(reminder.schedule_iteration_num, 2)
    self.assertEqual(reminder.current_event_sequence_num, 0)
    self.assertEqual(reminder.last_fired, CaseReminderHandler.now)
    CaseReminderHandler.now = datetime(year=2012, month=1, day=9, hour=10, minute=0)
    CaseReminderHandler.fire_reminders()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=12, hour=11, minute=0))
    self.assertEqual(reminder.schedule_iteration_num, 2)
    self.assertEqual(reminder.current_event_sequence_num, 1)
    self.assertEqual(reminder.last_fired, CaseReminderHandler.now)
    CaseReminderHandler.now = datetime(year=2012, month=1, day=12, hour=11, minute=0)
    CaseReminderHandler.fire_reminders()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=12, hour=11, minute=30))
    self.assertEqual(reminder.schedule_iteration_num, 2)
    self.assertEqual(reminder.current_event_sequence_num, 2)
    self.assertEqual(reminder.last_fired, CaseReminderHandler.now)
    CaseReminderHandler.now = datetime(year=2012, month=1, day=12, hour=11, minute=31)
    CaseReminderHandler.fire_reminders()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.schedule_iteration_num, 3)
    self.assertEqual(reminder.current_event_sequence_num, 0)
    self.assertEqual(reminder.last_fired, CaseReminderHandler.now)
    self.assertEqual(reminder.active, False)

dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/reminders/tests/__init__.py ReminderIrregularScheduleTestCase.test_ok/original