test_user_feedback.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. self.event_id = event.event_id
  10. self.create_userreport(
  11. date_added=timezone.now(),
  12. project=self.project,
  13. event_id=self.event_id,
  14. )
  15. self.url = f"/api/0/projects/{self.organization.slug}/{self.project.slug}/user-feedback/"
  16. self.login_as(user=self.user)
  17. def test_get(self):
  18. response = self.client.get(self.url)
  19. request = RequestFactory().get(self.url)
  20. self.validate_schema(request, response)
  21. def test_post(self):
  22. data = {
  23. "event_id": self.event_id,
  24. "name": "Hellboy",
  25. "email": "hellboy@sentry.io",
  26. "comments": "It broke!",
  27. }
  28. response = self.client.post(self.url, data)
  29. request = RequestFactory().post(self.url, data)
  30. self.validate_schema(request, response)