test_tasks.py 684 B

123456789101112131415161718
  1. from model_bakery import baker
  2. from glitchtip.test_utils.test_case import GlitchTipTestCase
  3. from ..maintenance import cleanup_old_transaction_events
  4. from ..models import TransactionEvent, TransactionGroup
  5. class TasksTestCase(GlitchTipTestCase):
  6. def test_cleanup_old_events(self):
  7. groups = baker.make("performance.TransactionGroup", _quantity=2)
  8. baker.make("performance.TransactionEvent", group=groups[0])
  9. cleanup_old_transaction_events()
  10. self.assertEqual(TransactionGroup.objects.count(), 1)
  11. TransactionEvent.objects.all().delete()
  12. cleanup_old_transaction_events()
  13. self.assertEqual(TransactionGroup.objects.count(), 0)