test_user_feedback.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from django.test.client import RequestFactory
  2. from django.utils import timezone
  3. from fixtures.apidocs_test_case import APIDocsTestCase
  4. from sentry.testutils.silo import region_silo_test
  5. @region_silo_test
  6. class ProjectUserFeedbackDocs(APIDocsTestCase):
  7. def setUp(self):
  8. event = self.create_event("a", message="oh no")
  9. group = self.create_group(project=self.project, message="Foo bar")
  10. self.event_id = event.event_id
  11. self.create_userreport(
  12. date_added=timezone.now(),
  13. group=group,
  14. project=self.project,
  15. event_id=self.event_id,
  16. )
  17. self.url = f"/api/0/projects/{self.organization.slug}/{self.project.slug}/user-feedback/"
  18. self.login_as(user=self.user)
  19. def test_get(self):
  20. response = self.client.get(self.url)
  21. request = RequestFactory().get(self.url)
  22. self.validate_schema(request, response)
  23. def test_post(self):
  24. data = {
  25. "event_id": self.event_id,
  26. "name": "Hellboy",
  27. "email": "hellboy@sentry.io",
  28. "comments": "It broke!",
  29. }
  30. response = self.client.post(self.url, data)
  31. request = RequestFactory().post(self.url, data)
  32. self.validate_schema(request, response)