diff --git a/hc/api/tests/test_pause.py b/hc/api/tests/test_pause.py index 4a86518a..eb9e8d0d 100644 --- a/hc/api/tests/test_pause.py +++ b/hc/api/tests/test_pause.py @@ -1,3 +1,5 @@ +from datetime import timedelta as td + from django.utils.timezone import now from hc.api.models import Check from hc.test import BaseTestCase @@ -57,8 +59,10 @@ class PauseTestCase(BaseTestCase): self.assertEqual(r.status_code, 404) - def test_it_clears_last_start(self): - check = Check(user=self.alice, status="up", last_start=now()) + def test_it_clears_last_start_alert_after(self): + check = Check(user=self.alice, status="up") + check.last_start = now() + check.alert_after = check.last_start + td(hours=1) check.save() url = "/api/v1/checks/%s/pause" % check.code @@ -70,3 +74,4 @@ class PauseTestCase(BaseTestCase): check.refresh_from_db() self.assertEqual(check.last_start, None) + self.assertEqual(check.alert_after, None) diff --git a/hc/api/views.py b/hc/api/views.py index d9f5c624..6c322497 100644 --- a/hc/api/views.py +++ b/hc/api/views.py @@ -189,6 +189,7 @@ def pause(request, code): check.status = "paused" check.last_start = None + check.alert_after = None check.save() return JsonResponse(check.to_dict()) diff --git a/hc/front/tests/test_pause.py b/hc/front/tests/test_pause.py index 4c64a4b6..d06da671 100644 --- a/hc/front/tests/test_pause.py +++ b/hc/front/tests/test_pause.py @@ -1,3 +1,5 @@ +from datetime import timedelta as td + from django.utils.timezone import now from hc.api.models import Check from hc.test import BaseTestCase @@ -33,8 +35,9 @@ class PauseTestCase(BaseTestCase): r = self.client.post(self.url) self.assertRedirects(r, "/checks/") - def test_it_clears_last_start(self): + def test_it_clears_last_start_alert_after(self): self.check.last_start = now() + self.check.alert_after = self.check.last_start + td(hours=1) self.check.save() self.client.login(username="alice@example.org", password="password") @@ -42,3 +45,4 @@ class PauseTestCase(BaseTestCase): self.check.refresh_from_db() self.assertEqual(self.check.last_start, None) + self.assertEqual(self.check.alert_after, None) diff --git a/hc/front/views.py b/hc/front/views.py index 4efaf7bd..eb4087ef 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -353,6 +353,7 @@ def pause(request, code): check.status = "paused" check.last_start = None + check.alert_after = None check.save() if "/details/" in request.META.get("HTTP_REFERER", ""):