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


Python ScheduledCall.calculate_next_run方法代码示例

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


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

示例1: test_now

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

        now = datetime.utcnow().replace(tzinfo=dateutils.utc_tz())
        next_run = dateutils.parse_iso8601_datetime(call.calculate_next_run())

        self.assertTrue(next_run - now < timedelta(seconds=1))
开发者ID:aweiteka,项目名称:pulp,代码行数:9,代码来源:test_dispatch.py

示例2: test_future

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

        next_run = call.calculate_next_run()

        # make sure the next run is equal to the specified first run.
        # don't want to compare a generated ISO8601 string directly, because there
        # could be subtle variations that are valid but break string equality.
        self.assertEqual(dateutils.parse_iso8601_interval(call.iso_schedule)[1],
                         dateutils.parse_iso8601_datetime(next_run))
开发者ID:aweiteka,项目名称:pulp,代码行数:13,代码来源:test_dispatch.py

示例3: test_with_past_runs

# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import calculate_next_run [as 别名]
    def test_with_past_runs(self, mock_time):
        # setup an hourly call that first ran not quite 2 hours ago, ran again
        # less than one hour ago, and should be scheduled to run at the end of
        # this hour
        mock_time.return_value = 1389389758.547976
        call = ScheduledCall('2014-01-10T20:00Z/PT1H', 'pulp.tasks.dosomething',
                             total_run_count=2, last_run_at='2014-01-10T21:00Z')

        next_run = call.calculate_next_run()

        self.assertEqual(dateutils.parse_iso8601_datetime('2014-01-10T22:00Z'),
                         dateutils.parse_iso8601_datetime(next_run))
开发者ID:aweiteka,项目名称:pulp,代码行数:14,代码来源:test_dispatch.py

示例4: test_with_years_duration

# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import calculate_next_run [as 别名]
    def test_with_years_duration(self, mock_time):
        """
        Test calculating the next run when the interval is a Duration object and uses years
        """
        last_runs = ('2015-01-01T10:00Z', '2016-01-01T10:00Z', '2017-01-01T10:00Z', '2018-01-01T10:00Z')
        expected_next_runs = ('2016-01-01T10:00Z', '2017-01-01T10:00Z', '2018-01-01T10:00Z', '2019-01-01T10:00Z')
        times = (
            1451642000.0,  # Just before 2016-01-01T10:00Z UTC
            1483264000.0,  # Just before 2017-01-01T10:00Z UTC
            1514800000.0,  # Just before 2018-01-01T10:00Z UTC
            1546336000.0,  # Just before 2019-01-01T10:00Z UTC
        )

        for last_run, current_time, expected_next_run in zip(last_runs, times, expected_next_runs):
            mock_time.return_value = current_time
            call = ScheduledCall('2014-01-01T10:00Z/P1M', 'pulp.tasks.dosomething',
                                 total_run_count=2, last_run_at=last_run)
            next_run = call.calculate_next_run()

            self.assertEqual(dateutils.parse_iso8601_datetime(expected_next_run),
                             dateutils.parse_iso8601_datetime(next_run))
开发者ID:unixbhaskar,项目名称:pulp,代码行数:23,代码来源:test_dispatch.py

示例5: test_with_months_duration

# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import calculate_next_run [as 别名]
    def test_with_months_duration(self, mock_time):
        """
        Test calculating the next run when the interval is a Duration object and uses months
        """
        last_runs = ('2015-01-01T10:00Z', '2015-02-01T10:00Z', '2015-03-01T10:00Z', '2015-04-01T10:00Z')
        expected_next_runs = ('2015-02-01T10:00Z', '2015-03-01T10:00Z', '2015-04-01T10:00Z', '2015-05-01T10:00Z')
        times = (
            1422784799.0,  # Just before 2015-02-01T10:00Z UTC
            1425203999.0,  # Just before 2015-03-01T10:00Z UTC
            1427882399.0,  # Just before 2015-04-01T10:00Z UTC
            1430474399.0,  # Just before 2015-05-01T10:00Z UTC
        )

        for last_run, current_time, expected_next_run in zip(last_runs, times, expected_next_runs):
            mock_time.return_value = current_time
            call = ScheduledCall('2014-12-01T10:00Z/P1M', 'pulp.tasks.dosomething',
                                 total_run_count=2, last_run_at=last_run)
            next_run = call.calculate_next_run()

            self.assertEqual(dateutils.parse_iso8601_datetime(expected_next_run),
                             dateutils.parse_iso8601_datetime(next_run))
开发者ID:unixbhaskar,项目名称:pulp,代码行数:23,代码来源:test_dispatch.py


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