test_group_events.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/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 = f"/api/0/issues/{self.group_id}/events/latest/"
  36. def test_get(self):
  37. response = self.client.get(self.url)
  38. request = RequestFactory().get(self.url)
  39. self.validate_schema(request, response)
  40. @region_silo_test
  41. class ProjectGroupEventsOldestDocs(ProjectGroupEventBase):
  42. def setUp(self):
  43. super().setUp()
  44. self.url = f"/api/0/issues/{self.group_id}/events/oldest/"
  45. def test_get(self):
  46. response = self.client.get(self.url)
  47. request = RequestFactory().get(self.url)
  48. self.validate_schema(request, response)