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.

24 lines
640 B

  1. from datetime import timedelta
  2. from django.utils import timezone
  3. from hc.api.management.commands.prunepingsslow import Command
  4. from hc.api.models import Check, Ping
  5. from hc.test import BaseTestCase
  6. class PrunePingsSlowTestCase(BaseTestCase):
  7. year_ago = timezone.now() - timedelta(days=365)
  8. def test_it_removes_old_pings(self):
  9. self.profile.ping_log_limit = 1
  10. self.profile.save()
  11. c = Check(project=self.project, n_pings=2)
  12. c.save()
  13. Ping.objects.create(owner=c, n=1)
  14. Ping.objects.create(owner=c, n=2)
  15. Command().handle()
  16. self.assertEqual(Ping.objects.count(), 1)