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


Python PactPatientCase.set_schedule方法代码示例

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


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

示例1: testExtendingPatientSchedule

# 需要导入模块: from pact.models import PactPatientCase [as 别名]
# 或者: from pact.models.PactPatientCase import set_schedule [as 别名]
    def testExtendingPatientSchedule(self):
        def fmt_datetime(dt):
            """Hacky timezone somewhat aware way to get date outputs right"""
            return utc.localize(dt).strftime("%Y-%m-%dT%H:%M:%SZ")
            #return dt.strftime("%Y-%m-%dT%H:%M:%SZ")


        test_patient = PactPatientCase()
        test_patient.computed_ = {}

        #hand make it
        #test_patient.computed_[WEEKLY_SCHEDULE_KEY] = [CDotWeeklySchedule.wrap(x) for x in WEEKLY_SCHEDULE_EXAMPLES]
        test_patient.computed_[WEEKLY_SCHEDULE_KEY] = WEEKLY_SCHEDULE_EXAMPLES

        #verify that tail is <date> - null
        api_schedules =  test_patient.get_schedules(raw_json=True)
        self.assertIsNone(api_schedules[-1]['ended'])
        self.assertEquals(api_schedules[-1]['started'], '2011-02-25T14:05:32Z')

        self.assertEquals(len(api_schedules), len(WEEKLY_SCHEDULE_EXAMPLES))

        #add a new schedule, verify tail is <date>-present, and [-2] is <datex> - <datey>


        test_patient.set_schedule(CDotWeeklySchedule.wrap(NEW_SCHEDULE))

        updated_schedules = test_patient.get_schedules(raw_json=True)
        self.assertIsNone(updated_schedules[-1]['ended'])
        self.assertEquals(len(updated_schedules), len(WEEKLY_SCHEDULE_EXAMPLES)+1)
        #pdb.set_trace()

        self.assertEquals(updated_schedules[-1]['started'][0:10], datetime.utcnow().isoformat()[0:10])

        self.assertIsNotNone(updated_schedules[-2]['ended'])
        print updated_schedules[-2]['ended']
        print datetime.utcnow().isoformat()
        self.assertLess(updated_schedules[-2]['ended'], datetime.utcnow().isoformat())

        ### remove tail
        test_patient.save()
        loaded_patient = PactPatientCase.get(test_patient.get_id)

        loaded_patient.rm_last_schedule()

        removed_schedules = loaded_patient.get_schedules(raw_json=True)
        self.assertEquals(len(removed_schedules), len(WEEKLY_SCHEDULE_EXAMPLES))
        self.assertIsNone(removed_schedules[-1]['ended'])
        self.assertEquals(removed_schedules[-1]['started'], '2011-02-25T14:05:32Z')
开发者ID:NoahCarnahan,项目名称:commcare-hq,代码行数:50,代码来源:schedules.py

示例2: testCreatePatientSchedule

# 需要导入模块: from pact.models import PactPatientCase [as 别名]
# 或者: from pact.models.PactPatientCase import set_schedule [as 别名]
    def testCreatePatientSchedule(self):
        """
        Single schedule create/remove
        """
        test_patient = PactPatientCase()
        test_patient.computed_ = {}
        test_patient.set_schedule(CDotWeeklySchedule.wrap(NEW_SCHEDULE))
        schedules = test_patient.get_schedules()

        self.assertEqual(len(schedules), 1)

        self.assertIsNone(schedules[0].ended)
        self.assertEquals(schedules[0].started.isoformat()[0:10], datetime.utcnow().isoformat()[0:10])
        self.assertTrue(schedules[0].is_current)
        test_patient.rm_last_schedule()
        updated_schedules = test_patient.get_schedules()

        self.assertEqual(len(updated_schedules), 0)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:20,代码来源:schedules.py

示例3: testExtendingPatientSchedule

# 需要导入模块: from pact.models import PactPatientCase [as 别名]
# 或者: from pact.models.PactPatientCase import set_schedule [as 别名]
    def testExtendingPatientSchedule(self):

        test_patient = PactPatientCase()
        test_patient.computed_ = {}

        # hand make it
        test_patient.computed_[WEEKLY_SCHEDULE_KEY] = WEEKLY_SCHEDULE_EXAMPLES

        # verify that tail is <date> - null
        api_schedules = test_patient.get_schedules(raw_json=True)
        self.assertIsNone(api_schedules[-1]['ended'])
        self.assertEquals(api_schedules[-1]['started'],
                          '2011-02-25T14:05:32Z')

        self.assertEquals(len(api_schedules), len(WEEKLY_SCHEDULE_EXAMPLES))

        # add a new schedule, verify tail is <date>-present, and [-2] is <datex> - <datey>

        test_patient.set_schedule(CDotWeeklySchedule.wrap(NEW_SCHEDULE))

        updated_schedules = test_patient.get_schedules(raw_json=True)
        self.assertIsNone(updated_schedules[-1]['ended'])
        self.assertEquals(len(updated_schedules), len(WEEKLY_SCHEDULE_EXAMPLES)+1)

        self.assertEquals(updated_schedules[-1]['started'][0:10], datetime.utcnow().isoformat()[0:10])

        self.assertIsNotNone(updated_schedules[-2]['ended'])
        self.assertLess(updated_schedules[-2]['ended'], datetime.utcnow().isoformat())

        # remove tail
        test_patient.save()
        loaded_patient = PactPatientCase.get(test_patient.get_id)

        loaded_patient.rm_last_schedule()

        removed_schedules = loaded_patient.get_schedules(raw_json=True)
        self.assertEquals(len(removed_schedules), len(WEEKLY_SCHEDULE_EXAMPLES))
        self.assertIsNone(removed_schedules[-1]['ended'])
        self.assertEquals(removed_schedules[-1]['started'],
                          '2011-02-25T14:05:32Z')
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:42,代码来源:schedules.py


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