forked from GithubBackups/healthchecks
Check.in_grace_period() should not blow up if last_ping is None
This commit is contained in:
parent
1f70f56819
commit
89d37f8202
@ -91,6 +91,9 @@ class Check(models.Model):
|
|||||||
return "down"
|
return "down"
|
||||||
|
|
||||||
def in_grace_period(self):
|
def in_grace_period(self):
|
||||||
|
if not self.last_ping:
|
||||||
|
return False
|
||||||
|
|
||||||
up_ends = self.last_ping + self.timeout
|
up_ends = self.last_ping + self.timeout
|
||||||
grace_ends = up_ends + self.grace
|
grace_ends = up_ends + self.grace
|
||||||
return up_ends < timezone.now() < grace_ends
|
return up_ends < timezone.now() < grace_ends
|
||||||
|
@ -13,3 +13,7 @@ class CheckModelTestCase(TestCase):
|
|||||||
|
|
||||||
check.tags = " "
|
check.tags = " "
|
||||||
self.assertEquals(check.tags_list(), [])
|
self.assertEquals(check.tags_list(), [])
|
||||||
|
|
||||||
|
def test_in_grace_period_handles_new_check(self):
|
||||||
|
check = Check()
|
||||||
|
self.assertFalse(check.in_grace_period())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user