You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

30 lines
993 B

from datetime import timedelta as td
from django.test import TestCase
from django.utils import timezone
from hc.api.models import Check
class CheckModelTestCase(TestCase):
def test_it_handles_new_check(self):
check = Check()
self.assertEqual(check.get_alert_after(), None)
def test_it_handles_paused_check(self):
check = Check()
check.last_ping = timezone.now() - td(days=2)
self.assertEqual(check.get_alert_after(), None)
def test_it_handles_up(self):
check = Check(status="up")
check.last_ping = timezone.now() - td(hours=1)
expected_aa = check.last_ping + td(days=1, hours=1)
self.assertEqual(check.get_alert_after(), expected_aa)
def test_it_handles_paused_then_started_check(self):
check = Check(status="paused")
check.last_start = timezone.now() - td(days=2)
expected_aa = check.last_start + td(hours=1)
self.assertEqual(check.get_alert_after(), expected_aa)