diff --git a/hc/api/models.py b/hc/api/models.py index 17d422fe..ee702b8f 100644 --- a/hc/api/models.py +++ b/hc/api/models.py @@ -97,7 +97,7 @@ class Check(models.Model): """ Return the datetime when grace period starts. """ # The common case, grace starts after timeout - if not self.schedule: + if self.kind == "simple": return self.last_ping + self.timeout # The complex case, next ping is expected based on cron schedule diff --git a/hc/api/tests/test_check_model.py b/hc/api/tests/test_check_model.py index 6eb0b736..ad347558 100644 --- a/hc/api/tests/test_check_model.py +++ b/hc/api/tests/test_check_model.py @@ -43,7 +43,7 @@ class CheckModelTestCase(TestCase): # Expect ping every midnight, default grace is 1 hour check = Check() - check.timeout = timedelta(minutes=0) + check.kind = "cron" check.schedule = "0 0 * * *" check.status = "up" check.last_ping = dt @@ -61,7 +61,7 @@ class CheckModelTestCase(TestCase): # Expect ping every day at 10am, default grace is 1 hour check = Check() - check.timeout = timedelta(minutes=0) + check.kind = "cron" check.schedule = "0 10 * * *" check.status = "up" check.last_ping = dt