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


Python Check.last_ping方法代码示例

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


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

示例1: test_status_works_with_grace_period

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

示例2: test_it_handles_grace_period

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

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

示例3: test_paused_check_is_not_in_grace_period

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

示例4: test_it_works_synchronously

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

示例5: test_it_skips_nag_if_none_down

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import last_ping [as 别名]
    def test_it_skips_nag_if_none_down(self):
        check = Check(name="Test Check", user=self.alice)
        check.last_ping = now()
        check.save()

        self.profile.nag_period = td(hours=1)
        self.profile.save()

        sent = self.profile.send_report(nag=True)
        self.assertFalse(sent)

        self.assertEqual(len(mail.outbox), 0)
开发者ID:cogzidel,项目名称:healthchecks,代码行数:14,代码来源:test_profile.py

示例6: test_next_ping_with_cron_syntax

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

示例7: test_it_updates_owners_next_nag_date

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

示例8: test_it_sends_report

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import last_ping [as 别名]
    def test_it_sends_report(self):
        check = Check(name="Test Check", user=self.alice)
        check.last_ping = now()
        check.save()

        sent = self.profile.send_report()
        self.assertTrue(sent)

        # And an email should have been sent
        self.assertEqual(len(mail.outbox), 1)
        message = mail.outbox[0]

        self.assertEqual(message.subject, 'Monthly Report')
        self.assertIn("Test Check", message.body)
开发者ID:cogzidel,项目名称:healthchecks,代码行数:16,代码来源:test_profile.py

示例9: test_it_does_not_touch_already_set_next_nag_dates

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

示例10: test_it_notifies_when_check_goes_down

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

示例11: test_status_works_with_cron_syntax

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

示例12: test_it_sends_nag

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

示例13: test_status_works_with_timezone

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

示例14: test_it_updates_alert_after

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

示例15: test_it_notifies_when_check_goes_up

# 需要导入模块: from hc.api.models import Check [as 别名]
# 或者: from hc.api.models.Check import last_ping [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.last_ping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。