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.

25 lines
684 B

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