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


Python ScheduledCall.for_display方法代码示例

本文整理汇总了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])
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:35,代码来源:test_schedule.py

示例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])
开发者ID:signull,项目名称:pulp,代码行数:24,代码来源:test_schedule.py

示例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))
开发者ID:aweiteka,项目名称:pulp,代码行数:6,代码来源:test_dispatch.py


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