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


Python Check.get_alert_after方法代码示例

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


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

示例1: test_it_handles_grace_period

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import get_alert_after [as 别名]
    def test_it_handles_grace_period(self):
        check = Check(user=self.alice, status="up")
        # 1 day 30 minutes after ping the check is in grace period:
        check.last_ping = timezone.now() - timedelta(days=1, minutes=30)
        check.alert_after = check.get_alert_after()
        check.save()

        # Expect no exceptions--
        Command().handle_one()
开发者ID:healthchecks,项目名称:healthchecks,代码行数:11,代码来源:test_sendalerts.py

示例2: test_it_works_synchronously

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import get_alert_after [as 别名]
    def test_it_works_synchronously(self, mock_notify):
        check = Check(user=self.alice, status="up")
        check.last_ping = now() - timedelta(days=2)
        check.alert_after = check.get_alert_after()
        check.save()

        call_command("sendalerts", loop=False, use_threads=False)

        # It should call `notify` instead of `notify_on_thread`
        self.assertTrue(mock_notify.called)
开发者ID:cogzidel,项目名称:healthchecks,代码行数:12,代码来源:test_sendalerts.py

示例3: test_it_updates_owners_next_nag_date

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import get_alert_after [as 别名]
    def test_it_updates_owners_next_nag_date(self):
        self.profile.nag_period = timedelta(hours=1)
        self.profile.save()

        check = Check(user=self.alice, status="down")
        check.last_ping = now() - timedelta(days=2)
        check.alert_after = check.get_alert_after()
        check.save()

        notify(check.id, Mock())

        self.profile.refresh_from_db()
        self.assertIsNotNone(self.profile.next_nag_date)
开发者ID:cogzidel,项目名称:healthchecks,代码行数:15,代码来源:test_sendalerts.py

示例4: test_it_does_not_touch_already_set_next_nag_dates

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import get_alert_after [as 别名]
    def test_it_does_not_touch_already_set_next_nag_dates(self):
        original_nag_date = now() - timedelta(minutes=30)
        self.profile.nag_period = timedelta(hours=1)
        self.profile.next_nag_date = original_nag_date
        self.profile.save()

        check = Check(user=self.alice, status="down")
        check.last_ping = now() - timedelta(days=2)
        check.alert_after = check.get_alert_after()
        check.save()

        notify(check.id, Mock())

        self.profile.refresh_from_db()
        self.assertEqual(self.profile.next_nag_date, original_nag_date)
开发者ID:cogzidel,项目名称:healthchecks,代码行数:17,代码来源:test_sendalerts.py

示例5: test_it_notifies_when_check_goes_down

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import get_alert_after [as 别名]
    def test_it_notifies_when_check_goes_down(self, mock_notify):
        check = Check(user=self.alice, status="up")
        check.last_ping = timezone.now() - timedelta(days=2)
        check.alert_after = check.get_alert_after()
        check.save()

        result = Command().handle_one()

        # If it finds work, it should return True
        self.assertTrue(result)

        # It should change stored status to "down"
        check.refresh_from_db()
        self.assertEqual(check.status, "down")

        # It should call `notify`
        self.assertTrue(mock_notify.called)
开发者ID:healthchecks,项目名称:healthchecks,代码行数:19,代码来源:test_sendalerts.py

示例6: test_it_notifies_when_check_goes_up

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import get_alert_after [as 别名]
    def test_it_notifies_when_check_goes_up(self, mock_notify):
        check = Check(user=self.alice, status="down")
        check.last_ping = now()
        check.alert_after = check.get_alert_after()
        check.save()

        result = Command().handle_one()

        # If it finds work, it should return True
        self.assertTrue(result)

        # It should change stored status to "up"
        check.refresh_from_db()
        self.assertEqual(check.status, "up")

        # It should call `notify_on_thread`
        self.assertTrue(mock_notify.called)

        # alert_after now should be set
        self.assertTrue(check.alert_after)
开发者ID:cogzidel,项目名称:healthchecks,代码行数:22,代码来源:test_sendalerts.py

示例7: UpdateTimeoutTestCase

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import get_alert_after [as 别名]
class UpdateTimeoutTestCase(BaseTestCase):

    def setUp(self):
        super(UpdateTimeoutTestCase, self).setUp()
        self.check = Check(user=self.alice)
        self.check.last_ping = timezone.now()
        self.check.save()

    def test_it_works(self):
        url = "/checks/%s/timeout/" % self.check.code
        payload = {"kind": "simple", "timeout": 3600, "grace": 60}

        self.client.login(username="[email protected]", password="password")
        r = self.client.post(url, data=payload)
        self.assertRedirects(r, "/checks/")

        self.check.refresh_from_db()
        self.assertEqual(self.check.kind, "simple")
        self.assertEqual(self.check.timeout.total_seconds(), 3600)
        self.assertEqual(self.check.grace.total_seconds(), 60)

        # alert_after should be updated too
        self.assertEqual(self.check.alert_after, self.check.get_alert_after())

    def test_it_saves_cron_expression(self):
        url = "/checks/%s/timeout/" % self.check.code
        payload = {
            "kind": "cron",
            "schedule": "* * * * *",
            "tz": "UTC",
            "timeout": 60,
            "grace": 60
        }

        self.client.login(username="[email protected]", password="password")
        r = self.client.post(url, data=payload)
        self.assertRedirects(r, "/checks/")

        self.check.refresh_from_db()
        self.assertEqual(self.check.kind, "cron")
        self.assertEqual(self.check.schedule, "* * * * *")

    def test_team_access_works(self):
        url = "/checks/%s/timeout/" % self.check.code
        payload = {"kind": "simple", "timeout": 7200, "grace": 60}

        # Logging in as bob, not alice. Bob has team access so this
        # should work.
        self.client.login(username="[email protected]", password="password")
        self.client.post(url, data=payload)

        check = Check.objects.get(code=self.check.code)
        assert check.timeout.total_seconds() == 7200

    def test_it_handles_bad_uuid(self):
        url = "/checks/not-uuid/timeout/"
        payload = {"timeout": 3600, "grace": 60}

        self.client.login(username="[email protected]", password="password")
        r = self.client.post(url, data=payload)
        assert r.status_code == 400

    def test_it_handles_missing_uuid(self):
        # Valid UUID but there is no check for it:
        url = "/checks/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/timeout/"
        payload = {"timeout": 3600, "grace": 60}

        self.client.login(username="[email protected]", password="password")
        r = self.client.post(url, data=payload)
        assert r.status_code == 404

    def test_it_checks_ownership(self):
        url = "/checks/%s/timeout/" % self.check.code
        payload = {"timeout": 3600, "grace": 60}

        self.client.login(username="[email protected]", password="password")
        r = self.client.post(url, data=payload)
        assert r.status_code == 403
开发者ID:healthchecks,项目名称:healthchecks,代码行数:80,代码来源:test_update_timeout.py


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