本文整理汇总了Python中hc.api.models.Check.status方法的典型用法代码示例。如果您正苦于以下问题:Python Check.status方法的具体用法?Python Check.status怎么用?Python Check.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hc.api.models.Check
的用法示例。
在下文中一共展示了Check.status方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_paused_check_is_not_in_grace_period
# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import status [as 别名]
def test_paused_check_is_not_in_grace_period(self):
check = Check()
check.status = "up"
check.last_ping = timezone.now() - timedelta(days=1, minutes=30)
self.assertTrue(check.in_grace_period())
check.status = "paused"
self.assertFalse(check.in_grace_period())
示例2: test_status_works_with_grace_period
# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import status [as 别名]
def test_status_works_with_grace_period(self):
check = Check()
check.status = "up"
check.last_ping = timezone.now() - timedelta(days=1, minutes=30)
self.assertTrue(check.in_grace_period())
self.assertEqual(check.get_status(), "up")
示例3: test_next_ping_with_cron_syntax
# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import status [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")
示例4: test_status_works_with_cron_syntax
# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import status [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")
示例5: test_it_sends_nag
# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import status [as 别名]
def test_it_sends_nag(self):
check = Check(name="Test Check", user=self.alice)
check.status = "down"
check.last_ping = now()
check.save()
self.profile.nag_period = td(hours=1)
self.profile.save()
sent = self.profile.send_report(nag=True)
self.assertTrue(sent)
# And an email should have been sent
self.assertEqual(len(mail.outbox), 1)
message = mail.outbox[0]
self.assertEqual(message.subject, 'Reminder: 1 check still down')
self.assertIn("Test Check", message.body)
示例6: test_it_handles_few
# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import status [as 别名]
def test_it_handles_few(self, mock):
yesterday = timezone.now() - timedelta(days=1)
names = ["Check %d" % d for d in range(0, 10)]
for name in names:
check = Check(user=self.alice, name=name)
check.alert_after = yesterday
check.status = "up"
check.save()
result = handle_many()
assert result, "handle_many should return True"
handled_names = []
for args, kwargs in mock.call_args_list:
handled_names.append(args[0].name)
assert set(names) == set(handled_names)
示例7: test_status_works_with_timezone
# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import status [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")
示例8: test_it_handles_few
# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import status [as 别名]
def test_it_handles_few(self, mock):
alice = User(username="alice")
alice.save()
names = ["Check %d" % d for d in range(0, 10)]
for name in names:
check = Check(user=alice, name=name)
check.alert_after = datetime(2000, 1, 1)
check.status = "up"
check.save()
result = handle_many()
assert result, "handle_many should return True"
handled_names = []
for args, kwargs in mock.call_args_list:
handled_names.append(args[0].name)
assert set(names) == set(handled_names)