test_group_events.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. from django.test.client import RequestFactory
  2. from fixtures.apidocs_test_case import APIDocsTestCase
  3. from sentry.testutils.helpers.datetime import before_now, iso_format
  4. from sentry.testutils.silo import region_silo_test
  5. class ProjectGroupEventBase(APIDocsTestCase):
  6. def setUp(self):
  7. first_release = {
  8. "firstEvent": before_now(minutes=3),
  9. "lastEvent": before_now(minutes=2, seconds=30),
  10. }
  11. last_release = {
  12. "firstEvent": before_now(minutes=1, seconds=30),
  13. "lastEvent": before_now(minutes=1),
  14. }
  15. for timestamp in first_release.values():
  16. self.create_event("a", release="1.0", timestamp=iso_format(timestamp))
  17. self.create_event("b", release="1.1")
  18. for timestamp in last_release.values():
  19. event = self.create_event("c", release="1.0a", timestamp=iso_format(timestamp))
  20. self.group_id = event.group.id
  21. self.login_as(user=self.user)
  22. @region_silo_test
  23. class ProjectGroupEventsDocs(ProjectGroupEventBase):
  24. def setUp(self):
  25. super().setUp()
  26. self.url = f"/api/0/organizations/{self.organization.slug}/issues/{self.group_id}/events/"
  27. def test_get(self):
  28. response = self.client.get(self.url)
  29. request = RequestFactory().get(self.url)
  30. self.validate_schema(request, response)
  31. @region_silo_test
  32. class ProjectGroupEventsLatestDocs(ProjectGroupEventBase):
  33. def setUp(self):
  34. super().setUp()
  35. self.url = (
  36. f"/api/0/organizations/{self.organization.slug}/issues/{self.group_id}/events/latest/"
  37. )
  38. def test_get(self):
  39. response = self.client.get(self.url)
  40. request = RequestFactory().get(self.url)
  41. self.validate_schema(request, response)
  42. @region_silo_test
  43. class ProjectGroupEventsOldestDocs(ProjectGroupEventBase):
  44. def setUp(self):
  45. super().setUp()
  46. self.url = (
  47. f"/api/0/organizations/{self.organization.slug}/issues/{self.group_id}/events/oldest/"
  48. )
  49. def test_get(self):
  50. response = self.client.get(self.url)
  51. request = RequestFactory().get(self.url)
  52. self.validate_schema(request, response)