当前位置: 首页>>代码示例>>Python>>正文


Python CaseReminderHandler.fire_reminders方法代码示例

本文整理汇总了Python中corehq.apps.reminders.models.CaseReminderHandler.fire_reminders方法的典型用法代码示例。如果您正苦于以下问题:Python CaseReminderHandler.fire_reminders方法的具体用法?Python CaseReminderHandler.fire_reminders怎么用?Python CaseReminderHandler.fire_reminders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在corehq.apps.reminders.models.CaseReminderHandler的用法示例。


在下文中一共展示了CaseReminderHandler.fire_reminders方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fire_reminders

# 需要导入模块: from corehq.apps.reminders.models import CaseReminderHandler [as 别名]
# 或者: from corehq.apps.reminders.models.CaseReminderHandler import fire_reminders [as 别名]
 def fire_reminders():
     CaseReminderHandler.fire_reminders()
开发者ID:johan--,项目名称:commcare-hq,代码行数:4,代码来源:tasks.py

示例2: testOutbound

# 需要导入模块: from corehq.apps.reminders.models import CaseReminderHandler [as 别名]
# 或者: from corehq.apps.reminders.models.CaseReminderHandler import fire_reminders [as 别名]
    def testOutbound(self):
        # Send an outbound call using self.reminder1 to self.case
        # and answer it
        CaseReminderHandler.now = datetime(2014, 6, 23, 10, 0)
        self.case = CommCareCase.get(register_sms_contact(
            self.domain,
            'participant',
            'case1',
            self.user1._id,
            '91000',
            owner_id=self.groups[0]._id,
            contact_ivr_backend_id='MOBILE_BACKEND_KOOKOO'
        ))
        CaseReminderHandler.now = datetime(2014, 6, 23, 12, 0)
        CaseReminderHandler.fire_reminders()
        reminder = self.reminder1.get_reminder(self.case)
        self.assertEquals(reminder.next_fire, datetime(2014, 6, 23, 12, 30))

        call = self.get_last_outbound_call(self.case)
        self.assertTrue(call.use_precached_first_response)

        kookoo_session_id = call.gateway_session_id[7:]
        resp = self.kookoo_in({
            "cid": "0000",
            "sid": kookoo_session_id,
            "event": "NewCall",
        })
        self.assertEqual(resp, '<response sid="%s"><collectdtmf l="1" o="3000">'
            '<playtext>How do you feel today? Press 1 for good, 2 for bad.'
            '</playtext></collectdtmf></response>' % kookoo_session_id)

        resp = self.kookoo_in({
            "cid": "0000",
            "sid": kookoo_session_id,
            "event": "GotDTMF",
            "data": "1",
        })
        self.assertEqual(resp, '<response sid="%s"><collectdtmf l="1" o="3000">'
            '<playtext>Did you remember to take your meds today? Press 1 for yes, 2 for no.'
            '</playtext></collectdtmf></response>' % kookoo_session_id)

        resp = self.kookoo_in({
            "cid": "0000",
            "sid": kookoo_session_id,
            "event": "GotDTMF",
            "data": "2",
        })
        self.assertEqual(resp, '<response sid="%s"><hangup/></response>' % kookoo_session_id)

        self.kookoo_finished({
            "sid": kookoo_session_id,
            "status": "answered",
            "duration": "20",
        })

        call = CallLog.get(call._id)
        self.assertTrue(call.answered)
        self.assertEqual(call.duration, 20)

        form = self.get_last_form_submission()
        self.assertFormQuestionEquals(form, "how_feel", "1")
        self.assertFormQuestionEquals(form, "take_meds", "2")
        case = CommCareCase.get(self.case._id)
        self.assertCasePropertyEquals(case, "how_feel", "1")
        self.assertCasePropertyEquals(case, "take_meds", "2")

        CaseReminderHandler.now = datetime(2014, 6, 23, 12, 30)
        CaseReminderHandler.fire_reminders()

        reminder = self.reminder1.get_reminder(self.case)
        self.assertEquals(reminder.next_fire, datetime(2014, 6, 23, 13, 0))

        last_call = self.get_last_outbound_call(self.case)
        self.assertEqual(call._id, last_call._id)

        # Move on to the second event which now uses an all-label form and
        # should not precache the first ivr response
        CaseReminderHandler.now = datetime(2014, 6, 23, 13, 0)
        CaseReminderHandler.fire_reminders()

        reminder = self.reminder1.get_reminder(self.case)
        self.assertEquals(reminder.next_fire, datetime(2014, 6, 23, 13, 30))

        call = self.get_last_outbound_call(self.case)
        self.assertFalse(call.use_precached_first_response)

        kookoo_session_id = call.gateway_session_id[7:]
        resp = self.kookoo_in({
            "cid": "0000",
            "sid": kookoo_session_id,
            "event": "NewCall",
        })
        self.assertEqual(resp, '<response sid="%s">'
            '<playtext>This is just a reminder to take your meds.'
            '</playtext><hangup/></response>' % kookoo_session_id)

        self.kookoo_finished({
            "sid": kookoo_session_id,
            "status": "answered",
            "duration": "5",
#.........这里部分代码省略.........
开发者ID:philipkaare,项目名称:commcare-hq,代码行数:103,代码来源:outbound.py

示例3: test_ok

# 需要导入模块: from corehq.apps.reminders.models import CaseReminderHandler [as 别名]
# 或者: from corehq.apps.reminders.models.CaseReminderHandler import fire_reminders [as 别名]
    def test_ok(self):
        with create_test_case(self.domain, self.case_type, 'test-case', drop_signals=False,
                user_id=self.user.get_id) as case:

            self.assertIsNone(self.handler.get_reminder(case))

            # Spawn CaseReminder
            CaseReminderHandler.now = datetime(year=2011, month=12, day=31, hour=23, minute=0)
            update_case(self.domain, case.case_id, {'start_sending': 'ok'}, user_id=self.user.get_id)
            reminder = self.handler.get_reminder(case)
            self.assertIsNotNone(reminder)
            self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=1, hour=7, 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)

            ######################
            # Day1, 10:00 reminder
            CaseReminderHandler.now = datetime(year=2012, month=1, day=1, hour=7, minute=0)
            CaseReminderHandler.fire_reminders()
            reminder = self.handler.get_reminder(case)
            self.assertIsNotNone(reminder)
            self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=1, hour=8, minute=0))
            self.assertEqual(reminder.schedule_iteration_num, 1)
            self.assertEqual(reminder.current_event_sequence_num, 1)
            self.assertEqual(reminder.last_fired, CaseReminderHandler.now)

            # Day1, 11:00 reminder
            CaseReminderHandler.now = datetime(year=2012, month=1, day=1, hour=8, minute=1)
            CaseReminderHandler.fire_reminders()
            reminder = self.handler.get_reminder(case)
            self.assertIsNotNone(reminder)
            self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=1, hour=8, minute=15))
            self.assertEqual(reminder.schedule_iteration_num, 1)
            self.assertEqual(reminder.current_event_sequence_num, 1)
            self.assertEqual(reminder.last_fired, CaseReminderHandler.now)

            event = self.get_expected_callback(
                datetime(2012, 1, 1, 8, 1),
                self.user.get_id
            )
            self.assertIsNotNone(event)
            self.assertEqual(event.status, CALLBACK_PENDING)

            # Create a callback
            Call.objects.create(
                couch_recipient_doc_type='CommCareUser',
                couch_recipient=self.user.get_id,
                phone_number='14445551234',
                direction='I',
                date=datetime(year=2012, month=1, day=1, hour=8, minute=5)
            )

            # Day1, 11:15 timeout (should move on to next event)
            CaseReminderHandler.now = datetime(year=2012, month=1, day=1, hour=8, minute=15)
            CaseReminderHandler.fire_reminders()
            reminder = self.handler.get_reminder(case)
            self.assertIsNotNone(reminder)
            self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=1, hour=8, minute=45))
            self.assertEqual(reminder.schedule_iteration_num, 1)
            self.assertEqual(reminder.current_event_sequence_num, 1)
            self.assertEqual(reminder.last_fired, CaseReminderHandler.now)

            # Day1, 11:45 timeout (should move on to next event)
            CaseReminderHandler.now = datetime(year=2012, month=1, day=1, hour=8, minute=45)
            CaseReminderHandler.fire_reminders()
            reminder = self.handler.get_reminder(case)
            self.assertIsNotNone(reminder)
            self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=2, hour=7, minute=0))
            self.assertEqual(reminder.schedule_iteration_num, 2)
            self.assertEqual(reminder.current_event_sequence_num, 0)
            self.assertEqual(reminder.last_fired, CaseReminderHandler.now)

            event = self.get_expected_callback(
                datetime(2012, 1, 1, 8, 1),
                self.user.get_id
            )
            self.assertIsNotNone(event)
            self.assertEqual(event.status, CALLBACK_RECEIVED)

            ######################
            # Day2, 10:00 reminder
            CaseReminderHandler.now = datetime(year=2012, month=1, day=2, hour=7, minute=0)
            CaseReminderHandler.fire_reminders()
            reminder = self.handler.get_reminder(case)
            self.assertIsNotNone(reminder)
            self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=2, hour=8, minute=0))
            self.assertEqual(reminder.schedule_iteration_num, 2)
            self.assertEqual(reminder.current_event_sequence_num, 1)
            self.assertEqual(reminder.last_fired, CaseReminderHandler.now)

            # Day2, 11:00 reminder
            CaseReminderHandler.now = datetime(year=2012, month=1, day=2, hour=8, minute=1)
            CaseReminderHandler.fire_reminders()
            reminder = self.handler.get_reminder(case)
            self.assertIsNotNone(reminder)
            self.assertEqual(reminder.next_fire, datetime(year=2012, month=1, day=2, hour=8, minute=15))
            self.assertEqual(reminder.schedule_iteration_num, 2)
            self.assertEqual(reminder.current_event_sequence_num, 1)
#.........这里部分代码省略.........
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:103,代码来源:test_send_reminders.py


注:本文中的corehq.apps.reminders.models.CaseReminderHandler.fire_reminders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。