test_statistics.py 1.1 KB

1234567891011121314151617181920212223242526272829
  1. from django.utils import timezone
  2. from model_bakery import baker
  3. from glitchtip.test_utils.test_case import GlitchTipTestCase
  4. from ..models import EventProjectHourlyStatistic, TransactionEventProjectHourlyStatistic
  5. class ProjectStatisticsTestCase(GlitchTipTestCase):
  6. def setUp(self):
  7. self.project = baker.make("projects.Project")
  8. def test_event_update_count(self):
  9. baker.make("events.Event", issue__project=self.project)
  10. EventProjectHourlyStatistic.update(self.project.pk, timezone.now())
  11. self.assertTrue(
  12. EventProjectHourlyStatistic.objects.filter(
  13. project=self.project, count=1
  14. ).exists()
  15. )
  16. def test_transaction_event_update_count(self):
  17. baker.make("performance.TransactionEvent", group__project=self.project)
  18. TransactionEventProjectHourlyStatistic.update(self.project.pk, timezone.now())
  19. self.assertTrue(
  20. TransactionEventProjectHourlyStatistic.objects.filter(
  21. project=self.project, count=1
  22. ).exists()
  23. )