本文整理汇总了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))