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


Python PactPatientCase.computed_[WEEKLY_SCHEDULE_KEY]方法代码示例

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


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

示例1: testExtendingPatientSchedule

# 需要导入模块: from pact.models import PactPatientCase [as 别名]
# 或者: from pact.models.PactPatientCase import computed_[WEEKLY_SCHEDULE_KEY] [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: testExtendingPatientSchedule

# 需要导入模块: from pact.models import PactPatientCase [as 别名]
# 或者: from pact.models.PactPatientCase import computed_[WEEKLY_SCHEDULE_KEY] [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.computed_[WEEKLY_SCHEDULE_KEY]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。