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


Python ScheduledCall.as_schedule_entry方法代码示例

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


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

示例1: test_no_last_run

# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import as_schedule_entry [as 别名]
    def test_no_last_run(self):
        call = ScheduledCall('PT1M', 'pulp.tasks.dosomething')

        entry = call.as_schedule_entry()

        # celery actually calculates it, so we don't need to test the value
        self.assertTrue(isinstance(entry.last_run_at, datetime))
开发者ID:aweiteka,项目名称:pulp,代码行数:9,代码来源:test_dispatch.py

示例2: test_no_runs

# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import as_schedule_entry [as 别名]
    def test_no_runs(self):
        call = ScheduledCall('PT1H', 'pulp.tasks.dosomething')
        entry = call.as_schedule_entry()

        is_due, seconds = entry.is_due()

        self.assertTrue(is_due)
        # make sure this is very close to one hour
        self.assertTrue(3600 - seconds < 1)
开发者ID:aweiteka,项目名称:pulp,代码行数:11,代码来源:test_dispatch.py

示例3: TestScheduleEntryIsDue

# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import as_schedule_entry [as 别名]
class TestScheduleEntryIsDue(unittest.TestCase):
    def setUp(self):
        super(TestScheduleEntryIsDue, self).setUp()
        self.call = ScheduledCall('2014-01-19T17:15Z/PT1H', 'pulp.tasks.dosomething',
                                  remaining_runs=5)
        self.entry = self.call.as_schedule_entry()

    @mock.patch('time.time')
    def test_first_run_future(self, mock_time):
        mock_time.return_value = 1389307330

        is_due, seconds = self.entry.is_due()

        self.assertFalse(is_due)
        self.assertEqual(seconds, 844370)

    def test_no_runs(self):
        call = ScheduledCall('PT1H', 'pulp.tasks.dosomething')
        entry = call.as_schedule_entry()

        is_due, seconds = entry.is_due()

        self.assertTrue(is_due)
        # make sure this is very close to one hour
        self.assertTrue(3600 - seconds < 1)

    @mock.patch('time.time')
    def test_past_runs_due(self, mock_time):
        mock_time.return_value = 1389389758  # 2014-01-10T21:35:58
        # This call did not run at the top of the hour, so it is overdue and should
        # run now. Its next run will be back on the normal hourly schedule, at
        # the top of the next hour.
        call = ScheduledCall('2014-01-10T20:00Z/PT1H', 'pulp.tasks.dosomething',
                             last_run_at='2014-01-10T20:00Z', total_run_count=1)
        entry = call.as_schedule_entry()

        is_due, seconds = entry.is_due()

        self.assertTrue(is_due)
        # this was hand-calculated as the remaining time until the next hourly run
        self.assertEqual(seconds, 1442)

    @mock.patch('time.time')
    def test_past_runs_not_due(self, mock_time):
        mock_time.return_value = 1389389758  # 2014-01-10T21:35:58
        # This call ran at the top of the hour, so it does not need to run again
        # until the top of the next hour.
        call = ScheduledCall('2014-01-10T20:00Z/PT1H', 'pulp.tasks.dosomething',
                             last_run_at='2014-01-10T21:00Z', total_run_count=2)
        entry = call.as_schedule_entry()

        is_due, seconds = entry.is_due()

        self.assertFalse(is_due)
        # this was hand-calculated as the remaining time until the next hourly run
        self.assertEqual(seconds, 1442)
开发者ID:aweiteka,项目名称:pulp,代码行数:58,代码来源:test_dispatch.py

示例4: test_past_runs_not_due

# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import as_schedule_entry [as 别名]
    def test_past_runs_not_due(self, mock_time):
        mock_time.return_value = 1389389758  # 2014-01-10T21:35:58
        # This call ran at the top of the hour, so it does not need to run again
        # until the top of the next hour.
        call = ScheduledCall('2014-01-10T20:00Z/PT1H', 'pulp.tasks.dosomething',
                             last_run_at='2014-01-10T21:00Z', total_run_count=2)
        entry = call.as_schedule_entry()

        is_due, seconds = entry.is_due()

        self.assertFalse(is_due)
        # this was hand-calculated as the remaining time until the next hourly run
        self.assertEqual(seconds, 1442)
开发者ID:aweiteka,项目名称:pulp,代码行数:15,代码来源:test_dispatch.py

示例5: test_past_runs_due

# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import as_schedule_entry [as 别名]
    def test_past_runs_due(self, mock_time):
        mock_time.return_value = 1389389758  # 2014-01-10T21:35:58
        # This call did not run at the top of the hour, so it is overdue and should
        # run now. Its next run will be back on the normal hourly schedule, at
        # the top of the next hour.
        call = ScheduledCall('2014-01-10T20:00Z/PT1H', 'pulp.tasks.dosomething',
                             last_run_at='2014-01-10T20:00Z', total_run_count=1)
        entry = call.as_schedule_entry()

        is_due, seconds = entry.is_due()

        self.assertTrue(is_due)
        # this was hand-calculated as the remaining time until the next hourly run
        self.assertEqual(seconds, 1442)
开发者ID:aweiteka,项目名称:pulp,代码行数:16,代码来源:test_dispatch.py

示例6: TestScheduleEntryNextInstance

# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import as_schedule_entry [as 别名]
class TestScheduleEntryNextInstance(unittest.TestCase):
    def setUp(self):
        super(TestScheduleEntryNextInstance, self).setUp()
        self.call = ScheduledCall('2014-01-19T17:15Z/PT1H', 'pulp.tasks.dosomething',
                                  remaining_runs=5)
        self.entry = self.call.as_schedule_entry()

    def test_increments_last_run(self, mock_save):
        next_entry = next(self.entry)
        now = datetime.utcnow().replace(tzinfo=dateutils.utc_tz())

        self.assertTrue(now - next_entry.last_run_at < timedelta(seconds=1))

    def test_increments_run_count(self, mock_save):
        next_entry = next(self.entry)

        self.assertEqual(self.entry.total_run_count + 1, next_entry.total_run_count)

    def test_decrements_remaining_runs(self, mock_save):
        remaining = self.call.remaining_runs

        next(self.entry)

        self.assertEqual(remaining - 1, self.call.remaining_runs)

    def test_disables_for_remaining_runs(self, mock_save):
        self.call.remaining_runs = 1
        # just verify that we have the correct starting state
        self.assertTrue(self.call.enabled)

        next(self.entry)

        # call should have been disabled because the remaining_runs hit 0
        self.assertFalse(self.call.enabled)

    def test_calls_save(self, mock_save):
        next(self.entry)

        mock_save.assert_called_once_with()

    def test_returns_entry(self, mock_save):
        next_entry = next(self.entry)

        self.assertTrue(isinstance(next_entry, ScheduleEntry))
        self.assertEqual(self.entry.name, next_entry.name)
        self.assertFalse(self.entry is next_entry)
开发者ID:aweiteka,项目名称:pulp,代码行数:48,代码来源:test_dispatch.py

示例7: test_captures_scheduled_call

# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import as_schedule_entry [as 别名]
    def test_captures_scheduled_call(self):
        call = ScheduledCall('2014-01-19T17:15Z/PT1H', 'pulp.tasks.dosomething')
        entry = call.as_schedule_entry()

        self.assertTrue(hasattr(entry, '_scheduled_call'))
        self.assertTrue(entry._scheduled_call is call)
开发者ID:aweiteka,项目名称:pulp,代码行数:8,代码来源:test_dispatch.py


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