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


Python Timeperiod.is_time_valid方法代码示例

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


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

示例1: test_issue_1385

# 需要导入模块: from shinken.objects.timeperiod import Timeperiod [as 别名]
# 或者: from shinken.objects.timeperiod.Timeperiod import is_time_valid [as 别名]
    def test_issue_1385(self):
        '''
        https://github.com/naparuba/shinken/issues/1385
        '''
        tp = Timeperiod()
        tp.timeperiod_name = 'mercredi2-22-02'
        tp.resolve_daterange(tp.dateranges, 'wednesday 2              00:00-02:00,22:00-24:00')
        tp.resolve_daterange(tp.dateranges, 'thursday 2                00:00-02:00,22:00-24:00')

        valid_times = (
            (2014, 11, 12, 1, 0),  # second wednesday of november @ 01:00
            (2014, 11, 12, 23, 0), # same @23:00
            (2014, 11, 13, 0, 0), # second thursday @ 00:00
            # in december:
            (2014, 12, 10, 1, 0),
            (2014, 12, 10, 23, 0),
            (2014, 12, 11, 1, 0),
            (2014, 12, 11, 23, 0),

        )
        for valid in valid_times:
            dt = datetime.datetime(*valid)
            valid_tm = time.mktime(dt.timetuple())
            self.assertTrue(tp.is_time_valid(valid_tm))

        invalid_times = (
            (2014, 11, 3, 1, 0), # first wednesday ..
            (2014, 11, 4, 1, 0),  # first thursday
            (2014, 11, 17, 1, 0),   # third ..
            (2014, 11, 18, 1, 0),
            # in december:
            (2014, 12, 5, 3, 0),
            (2014, 12, 17, 1, 0),
            (2014, 12, 18, 1, 0),
            (2014, 12, 24, 1, 0),
            (2014, 12, 25, 1, 0),
            (2014, 12, 31, 1, 0),
        )
        for invalid in invalid_times:
            dt = datetime.datetime(*invalid)
            invalid_tm = time.mktime(dt.timetuple())
            self.assertFalse(tp.is_time_valid(invalid_tm))
开发者ID:,项目名称:,代码行数:44,代码来源:


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