test_group_events.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from django.test.client import RequestFactory
  2. from fixtures.apidocs_test_case import APIDocsTestCase
  3. from sentry.testutils.helpers.datetime import before_now
  4. class ProjectGroupEventBase(APIDocsTestCase):
  5. def setUp(self):
  6. first_release = {
  7. "firstEvent": before_now(minutes=3),
  8. "lastEvent": before_now(minutes=2, seconds=30),
  9. }
  10. last_release = {
  11. "firstEvent": before_now(minutes=1, seconds=30),
  12. "lastEvent": before_now(minutes=1),
  13. }
  14. for timestamp in first_release.values():
  15. self.create_event("a", release="1.0", timestamp=timestamp.isoformat())
  16. self.create_event("b", release="1.1")
  17. for timestamp in last_release.values():
  18. event = self.create_event("c", release="1.0a", timestamp=timestamp.isoformat())
  19. self.group_id = event.group.id
  20. self.login_as(user=self.user)
  21. class ProjectGroupEventsDocs(ProjectGroupEventBase):
  22. def setUp(self):
  23. super().setUp()
  24. self.url = f"/api/0/issues/{self.group_id}/events/"
  25. def test_get(self):
  26. response = self.client.get(self.url)
  27. request = RequestFactory().get(self.url)
  28. self.validate_schema(request, response)
  29. class ProjectGroupEventDetailsDocs(ProjectGroupEventBase):
  30. def setUp(self):
  31. super().setUp()
  32. self.url = f"/api/0/issues/{self.group_id}/events/latest/"
  33. def test_get(self):
  34. response = self.client.get(self.url)
  35. request = RequestFactory().get(self.url)
  36. self.validate_schema(request, response)