tests.py 729 B

123456789101112131415161718192021
  1. from django.urls import reverse
  2. from django.utils import timezone
  3. from model_bakery import baker
  4. from glitchtip.test_utils.test_case import GlitchTipTestCase
  5. class StatsV2APITestCase(GlitchTipTestCase):
  6. def setUp(self):
  7. self.create_user_and_project()
  8. self.url = reverse("api:stats_v2", args=[self.organization.slug])
  9. def test_get(self):
  10. baker.make("issue_events.IssueEvent", issue__project=self.project)
  11. start = timezone.now() - timezone.timedelta(hours=2)
  12. end = timezone.now()
  13. res = self.client.get(
  14. self.url,
  15. {"category": "error", "start": start, "end": end, "field": "sum(quantity)"},
  16. )
  17. self.assertEqual(res.status_code, 200)