本文整理汇总了Python中pulp.server.db.model.dispatch.ScheduledCall.for_display方法的典型用法代码示例。如果您正苦于以下问题:Python ScheduledCall.for_display方法的具体用法?Python ScheduledCall.for_display怎么用?Python ScheduledCall.for_display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.server.db.model.dispatch.ScheduledCall
的用法示例。
在下文中一共展示了ScheduledCall.for_display方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get
# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import for_display [as 别名]
def test_get(self, mock_path, mock_ok, mock_utils_get):
call = ScheduledCall('PT1M', 'pulp.tasks.frequent')
mock_utils_get.return_value = [call]
ret = self.controller._get(call.id)
schedule = mock_ok.call_args[0][0]
self.assertEqual(ret, mock_ok.return_value)
self.assertEqual(len(mock_ok.call_args[0]), 1)
# spot-check the schedule
self.assertEqual(schedule['_id'], call.id)
self.assertEqual(schedule['schedule'], 'PT1M')
self.assertEqual(schedule['task'], 'pulp.tasks.frequent')
self.assertEqual(schedule['_href'], mock_path.return_value)
# next_run is calculated on-demand, and there is a small chance that it
# will be re-calculated in the call.for_display() call as 1 second later
# than it was calculated above. Thus we will test that equality here
# with a tolerance of 1 second
for_display = call.for_display()
call_next_run = dateutils.parse_iso8601_datetime(call.next_run)
display_next_run = dateutils.parse_iso8601_datetime(for_display['next_run'])
self.assertTrue(display_next_run - call_next_run <= timedelta(seconds=1))
# now check overall equality with the actual for_display value
del schedule['_href']
del schedule['next_run']
del for_display['next_run']
self.assertEqual(schedule, for_display)
# make sure we called the manager layer correctly
mock_utils_get.assert_called_once_with([call.id])
示例2: test_get
# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import for_display [as 别名]
def test_get(self, mock_path, mock_ok, mock_utils_get):
call = ScheduledCall('PT1M', 'pulp.tasks.frequent')
mock_utils_get.return_value = [call]
ret = self.controller._get(call.id)
schedule = mock_ok.call_args[0][0]
self.assertEqual(ret, mock_ok.return_value)
self.assertEqual(len(mock_ok.call_args[0]), 1)
# spot-check the schedule
self.assertEqual(schedule['_id'], call.id)
self.assertEqual(schedule['schedule'], 'PT1M')
self.assertEqual(schedule['task'], 'pulp.tasks.frequent')
self.assertEqual(schedule['_href'], mock_path.return_value)
# now check overall equality with the actual for_display value
del schedule['_href']
self.assertEqual(schedule, call.for_display())
# make sure we called the manager layer correctly
mock_utils_get.assert_called_once_with([call.id])
示例3: test_returns_dict
# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import for_display [as 别名]
def test_returns_dict(self):
call = ScheduledCall('PT1M', 'pulp.tasks.dosomething')
self.assertTrue(isinstance(call.for_display(), dict))