test_group_events.py 2.1 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. 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=iso_format(timestamp))
  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=iso_format(timestamp))
  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/organizations/{self.organization.slug}/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 ProjectGroupEventsLatestDocs(ProjectGroupEventBase):
  30. def setUp(self):
  31. super().setUp()
  32. self.url = (
  33. f"/api/0/organizations/{self.organization.slug}/issues/{self.group_id}/events/latest/"
  34. )
  35. def test_get(self):
  36. response = self.client.get(self.url)
  37. request = RequestFactory().get(self.url)
  38. self.validate_schema(request, response)
  39. class ProjectGroupEventsOldestDocs(ProjectGroupEventBase):
  40. def setUp(self):
  41. super().setUp()
  42. self.url = (
  43. f"/api/0/organizations/{self.organization.slug}/issues/{self.group_id}/events/oldest/"
  44. )
  45. def test_get(self):
  46. response = self.client.get(self.url)
  47. request = RequestFactory().get(self.url)
  48. self.validate_schema(request, response)