This website works better with JavaScript.
Home
Explore
Help
Register
Sign In
nielsperetzke
/
healthchecks
Watch
1
Star
0
Fork
0
Code
Issues
0
Pull Requests
0
Projects
0
Releases
32
Wiki
Activity
Browse Source
Check.in_grace_period() should not blow up if last_ping is None
pull/64/head
Pēteris Caune
9 years ago
parent
1f70f56819
commit
89d37f8202
2 changed files
with
7 additions
and
0 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
+3
-0
hc/api/models.py
+4
-0
hc/api/tests/test_check_model.py
+ 3
- 0
hc/api/models.py
View File
@ -91,6 +91,9 @@ class Check(models.Model):
return
"
down
"
def
in_grace_period
(
self
)
:
if
not
self
.
last_ping
:
return
False
up_ends
=
self
.
last_ping
+
self
.
timeout
grace_ends
=
up_ends
+
self
.
grace
return
up_ends
<
timezone
.
now
(
)
<
grace_ends
+ 4
- 0
hc/api/tests/test_check_model.py
View File
@ -13,3 +13,7 @@ class CheckModelTestCase(TestCase):
check
.
tags
=
"
"
self
.
assertEquals
(
check
.
tags_list
(
)
,
[
]
)
def
test_in_grace_period_handles_new_check
(
self
)
:
check
=
Check
(
)
self
.
assertFalse
(
check
.
in_grace_period
(
)
)
Write
Preview
Loading…
Cancel
Save