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. class ProjectUserFeedbackDocs(APIDocsTestCase):
  5. def setUp(self):
  6. event = self.create_event("a", message="oh no")
  7. group = self.create_group(project=self.project, message="Foo bar")
  8. self.event_id = event.event_id
  9. self.create_userreport(
  10. date_added=timezone.now(),
  11. group=group,
  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)