本文整理汇总了Python中pact.models.PactPatientCase.get_schedules方法的典型用法代码示例。如果您正苦于以下问题:Python PactPatientCase.get_schedules方法的具体用法?Python PactPatientCase.get_schedules怎么用?Python PactPatientCase.get_schedules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pact.models.PactPatientCase
的用法示例。
在下文中一共展示了PactPatientCase.get_schedules方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testExtendingPatientSchedule
# 需要导入模块: from pact.models import PactPatientCase [as 别名]
# 或者: from pact.models.PactPatientCase import get_schedules [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')
示例2: testCreatePatientSchedule
# 需要导入模块: from pact.models import PactPatientCase [as 别名]
# 或者: from pact.models.PactPatientCase import get_schedules [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)
示例3: testExtendingPatientSchedule
# 需要导入模块: from pact.models import PactPatientCase [as 别名]
# 或者: from pact.models.PactPatientCase import get_schedules [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')