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

  1. from datetime import timedelta
  2. from django.test import TestCase
  3. from django.utils import timezone
  4. from hc.api.management.commands.ensuretriggers import Command
  5. from hc.api.models import Check
  6. class EnsureTriggersTestCase(TestCase):
  7. def test_ensure_triggers(self):
  8. Command().handle()
  9. check = Check.objects.create()
  10. assert check.alert_after is None
  11. check.last_ping = timezone.now()
  12. check.save()
  13. check.refresh_from_db()
  14. assert check.alert_after is not None
  15. alert_after = check.alert_after
  16. check.last_ping += timedelta(days=1)
  17. check.save()
  18. check.refresh_from_db()
  19. assert check.alert_after > alert_after