本文整理汇总了Python中hc.api.models.Check.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Check.delete方法的具体用法?Python Check.delete怎么用?Python Check.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hc.api.models.Check
的用法示例。
在下文中一共展示了Check.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SendAlertsTestCase
# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import delete [as 别名]
class SendAlertsTestCase(BaseTestCase):
def setUp(self):
super(SendAlertsTestCase, self).setUp()
# Make alice eligible for reports:
# account needs to be more than one month old
self.alice.date_joined = now() - td(days=365)
self.alice.save()
# Make alice eligible for nags:
self.profile.nag_period = td(hours=1)
self.profile.next_nag_date = now() - td(seconds=10)
self.profile.save()
# And it needs at least one check that has been pinged.
self.check = Check(user=self.alice, last_ping=now())
self.check.status = "down"
self.check.save()
def test_it_sends_report(self):
found = Command().handle_one_monthly_report()
self.assertTrue(found)
self.profile.refresh_from_db()
self.assertTrue(self.profile.next_report_date > now())
self.assertEqual(len(mail.outbox), 1)
def test_it_obeys_next_report_date(self):
self.profile.next_report_date = now() + td(days=1)
self.profile.save()
found = Command().handle_one_monthly_report()
self.assertFalse(found)
def test_it_obeys_reports_allowed_flag(self):
self.profile.reports_allowed = False
self.profile.save()
found = Command().handle_one_monthly_report()
self.assertFalse(found)
def test_it_requires_pinged_checks(self):
self.check.delete()
found = Command().handle_one_monthly_report()
self.assertTrue(found)
# No email should have been sent:
self.assertEqual(len(mail.outbox), 0)
def test_it_sends_nag(self):
found = Command().handle_one_nag()
self.assertTrue(found)
self.profile.refresh_from_db()
self.assertTrue(self.profile.next_nag_date > now())
self.assertEqual(len(mail.outbox), 1)
def test_it_obeys_next_nag_date(self):
self.profile.next_nag_date = now() + td(days=1)
self.profile.save()
# If next_nag_date is in future, a nag should not get sent.
found = Command().handle_one_nag()
self.assertFalse(found)
def test_it_obeys_nag_period(self):
self.profile.nag_period = td()
self.profile.save()
# If nag_period is 0 ("disabled"), a nag should not get sent.
found = Command().handle_one_nag()
self.assertFalse(found)
def test_nags_require_down_checks(self):
self.check.status = "up"
self.check.save()
found = Command().handle_one_nag()
self.assertTrue(found)
# No email should have been sent:
self.assertEqual(len(mail.outbox), 0)
# next_nag_date should now be unset
self.profile.refresh_from_db()
self.assertIsNone(self.profile.next_nag_date)