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


Python Check.alert_after方法代码示例

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


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

示例1: test_it_handles_grace_period

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import 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 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 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 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 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_handles_few

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import alert_after [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)
开发者ID:jjhuang,项目名称:healthchecks,代码行数:20,代码来源:test_sendalerts.py

示例7: test_it_updates_alert_after

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import alert_after [as 别名]
    def test_it_updates_alert_after(self, mock_notify):
        check = Check(user=self.alice, status="up")
        check.last_ping = timezone.now() - timedelta(hours=1)
        check.alert_after = check.last_ping
        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()

        # alert_after should have been increased
        self.assertTrue(check.alert_after > check.last_ping)

        # notify should *not* have been called
        self.assertFalse(mock_notify.called)
开发者ID:healthchecks,项目名称:healthchecks,代码行数:21,代码来源:test_sendalerts.py

示例8: test_it_handles_few

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import alert_after [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)
开发者ID:bobocola,项目名称:healthchecks,代码行数:22,代码来源:test_sendalerts.py

示例9: test_it_notifies_when_check_goes_up

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import 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


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