

def test_ok(self):
    self.assertEqual(self.handler.events[0].message['en'], self.message)
    self.assertEqual(self.handler.get_reminder(self.case), None)
    CaseReminderHandler.now = datetime(year=2011, month=7, day=7, hour=19, minute=8)
    set_case_property_directly(self.case, 'start_sending', 'ok')
    self.case.save()
    CaseReminderHandler.fire_reminders()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.next_fire, (CaseReminderHandler.now + timedelta(days=self.handler.start_offset)))
    self.assertEqual(reminder.last_fired, None)
    CaseReminderHandler.now = datetime(year=2011, month=7, day=8, hour=19, minute=8)
    set_case_property_directly(reminder.case, 'irrelevant_1', 'ok')
    self.case.save()
    CaseReminderHandler.fire_reminders()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.next_fire, (CaseReminderHandler.now + timedelta(days=self.handler.schedule_length)))
    self.assertEqual(reminder.last_fired, CaseReminderHandler.now)
    last_fired = CaseReminderHandler.now
    CaseReminderHandler.now = datetime(year=2011, month=7, day=9, hour=19, minute=8)
    CaseReminderHandler.fire_reminders()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.last_fired, last_fired)
    self.assertEqual(reminder.next_fire, (last_fired + timedelta(days=self.handler.schedule_length)))
    CaseReminderHandler.now = datetime(year=2011, month=7, day=11, hour=19, minute=8)
    set_case_property_directly(self.case, 'irrelevant_2', 'ok')
    self.case.save()
    CaseReminderHandler.fire_reminders()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.next_fire, (CaseReminderHandler.now + timedelta(days=self.handler.schedule_length)))
    self.assertEqual(reminder.last_fired, CaseReminderHandler.now)
    last_fired = CaseReminderHandler.now
    CaseReminderHandler.now = datetime(year=2011, month=7, day=14, hour=19, minute=8)
    set_case_property_directly(self.case, 'stop_sending', 'ok')
    self.case.save()
    CaseReminderHandler.fire_reminders()
    reminder = self.handler.get_reminder(self.case)
    self.assertNotEqual(reminder, None)
    self.assertEqual(reminder.last_fired, last_fired)
    self.assertEqual(reminder.active, False)

dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/reminders/tests/__init__.py ReminderTestCase.test_ok/VarMisuse@191/246 `self`->`reminder`