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.
 
 
 
 
 

27 lines
707 B

from datetime import timedelta
from django.test import TestCase
from django.utils import timezone
from hc.api.management.commands.ensuretriggers import Command
from hc.api.models import Check
class EnsureTriggersTestCase(TestCase):
def test_ensure_triggers(self):
Command().handle()
check = Check.objects.create()
assert check.alert_after is None
check.last_ping = timezone.now()
check.save()
check.refresh_from_db()
assert check.alert_after is not None
alert_after = check.alert_after
check.last_ping += timedelta(days=1)
check.save()
check.refresh_from_db()
assert check.alert_after > alert_after