test_maintenance.py 799 B

123456789101112131415161718192021222324
  1. from datetime import timedelta
  2. from uuid import uuid4
  3. from django.conf import settings
  4. from django.utils import timezone
  5. from model_bakery import baker
  6. from glitchtip.test_utils.test_case import GlitchTestCase
  7. from ..maintenance import cleanup_old_debug_symbol_bundles
  8. from ..models import DebugSymbolBundle
  9. class SourceCodeMaintenanceTestCase(GlitchTestCase):
  10. def test_cleanup(self):
  11. now = timezone.now()
  12. baker.make("sourcecode.DebugSymbolBundle", last_used=now, debug_id=uuid4())
  13. baker.make(
  14. "sourcecode.DebugSymbolBundle",
  15. last_used=now - timedelta(days=settings.GLITCHTIP_MAX_FILE_LIFE_DAYS),
  16. debug_id=uuid4()
  17. )
  18. cleanup_old_debug_symbol_bundles()
  19. self.assertEqual(DebugSymbolBundle.objects.count(), 1)