本文整理汇总了Python中hc.api.models.Check.schedule方法的典型用法代码示例。如果您正苦于以下问题:Python Check.schedule方法的具体用法?Python Check.schedule怎么用?Python Check.schedule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hc.api.models.Check
的用法示例。
在下文中一共展示了Check.schedule方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_next_ping_with_cron_syntax
# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import schedule [as 别名]
def test_next_ping_with_cron_syntax(self):
dt = timezone.make_aware(datetime(2000, 1, 1), timezone=timezone.utc)
# Expect ping every round hour
check = Check()
check.kind = "cron"
check.schedule = "0 * * * *"
check.status = "up"
check.last_ping = dt
d = check.to_dict()
self.assertEqual(d["next_ping"], "2000-01-01T01:00:00+00:00")
示例2: test_status_works_with_cron_syntax
# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import schedule [as 别名]
def test_status_works_with_cron_syntax(self):
dt = timezone.make_aware(datetime(2000, 1, 1), timezone=timezone.utc)
# Expect ping every midnight, default grace is 1 hour
check = Check()
check.kind = "cron"
check.schedule = "0 0 * * *"
check.status = "up"
check.last_ping = dt
# 00:30am
now = dt + timedelta(days=1, minutes=30)
self.assertEqual(check.get_status(now), "up")
# 1:30am
now = dt + timedelta(days=1, minutes=90)
self.assertEqual(check.get_status(now), "down")
示例3: test_status_works_with_timezone
# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import schedule [as 别名]
def test_status_works_with_timezone(self):
dt = timezone.make_aware(datetime(2000, 1, 1), timezone=timezone.utc)
# Expect ping every day at 10am, default grace is 1 hour
check = Check()
check.kind = "cron"
check.schedule = "0 10 * * *"
check.status = "up"
check.last_ping = dt
check.tz = "Australia/Brisbane" # UTC+10
# 10:30am
now = dt + timedelta(days=1, minutes=30)
self.assertEqual(check.get_status(now), "up")
# 11:30am
now = dt + timedelta(days=1, minutes=90)
self.assertEqual(check.get_status(now), "down")