test_user_feedback.py 1.1 KB

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