|
@ -10,17 +10,20 @@ class CheckModelTestCase(TestCase): |
|
|
def test_it_handles_new_check(self): |
|
|
def test_it_handles_new_check(self): |
|
|
check = Check() |
|
|
check = Check() |
|
|
self.assertEqual(check.get_alert_after(), None) |
|
|
self.assertEqual(check.get_alert_after(), None) |
|
|
|
|
|
self.assertFalse(check.is_down()) |
|
|
|
|
|
|
|
|
def test_it_handles_paused_check(self): |
|
|
def test_it_handles_paused_check(self): |
|
|
check = Check() |
|
|
check = Check() |
|
|
check.last_ping = timezone.now() - td(days=2) |
|
|
check.last_ping = timezone.now() - td(days=2) |
|
|
self.assertEqual(check.get_alert_after(), None) |
|
|
self.assertEqual(check.get_alert_after(), None) |
|
|
|
|
|
self.assertFalse(check.is_down()) |
|
|
|
|
|
|
|
|
def test_it_handles_up(self): |
|
|
def test_it_handles_up(self): |
|
|
check = Check(status="up") |
|
|
check = Check(status="up") |
|
|
check.last_ping = timezone.now() - td(hours=1) |
|
|
check.last_ping = timezone.now() - td(hours=1) |
|
|
expected_aa = check.last_ping + td(days=1, hours=1) |
|
|
expected_aa = check.last_ping + td(days=1, hours=1) |
|
|
self.assertEqual(check.get_alert_after(), expected_aa) |
|
|
self.assertEqual(check.get_alert_after(), expected_aa) |
|
|
|
|
|
self.assertFalse(check.is_down()) |
|
|
|
|
|
|
|
|
def test_it_handles_paused_then_started_check(self): |
|
|
def test_it_handles_paused_then_started_check(self): |
|
|
check = Check(status="paused") |
|
|
check = Check(status="paused") |
|
@ -28,3 +31,17 @@ class CheckModelTestCase(TestCase): |
|
|
|
|
|
|
|
|
expected_aa = check.last_start + td(hours=1) |
|
|
expected_aa = check.last_start + td(hours=1) |
|
|
self.assertEqual(check.get_alert_after(), expected_aa) |
|
|
self.assertEqual(check.get_alert_after(), expected_aa) |
|
|
|
|
|
self.assertTrue(check.is_down()) |
|
|
|
|
|
|
|
|
|
|
|
def test_it_handles_down(self): |
|
|
|
|
|
check = Check(status="down") |
|
|
|
|
|
check.last_ping = timezone.now() - td(hours=1) |
|
|
|
|
|
self.assertEqual(check.get_alert_after(), None) |
|
|
|
|
|
self.assertTrue(check.is_down()) |
|
|
|
|
|
|
|
|
|
|
|
def test_it_handles_down_then_started_check(self): |
|
|
|
|
|
check = Check(status="down") |
|
|
|
|
|
check.last_start = timezone.now() - td(minutes=10) |
|
|
|
|
|
|
|
|
|
|
|
self.assertEqual(check.get_alert_after(), None) |
|
|
|
|
|
self.assertTrue(check.is_down()) |