test_service_hook_details.py 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. from django.test.client import RequestFactory
  2. from django.urls import reverse
  3. from fixtures.apidocs_test_case import APIDocsTestCase
  4. class ProjectServiceHookDetailsDocs(APIDocsTestCase):
  5. def setUp(self):
  6. hook = self.create_service_hook(project=self.project, events=("event.created",))
  7. self.url = reverse(
  8. "sentry-api-0-project-service-hook-details",
  9. kwargs={
  10. "organization_slug": self.organization.slug,
  11. "project_id_or_slug": self.project.slug,
  12. "hook_id": hook.guid,
  13. },
  14. )
  15. self.login_as(user=self.user)
  16. def test_get(self):
  17. response = self.client.get(self.url)
  18. request = RequestFactory().get(self.url)
  19. self.validate_schema(request, response)
  20. def test_put(self):
  21. data = {"url": "https://example.com/other-sentry-hook", "events": ["event.created"]}
  22. response = self.client.put(self.url, data)
  23. request = RequestFactory().put(self.url, data)
  24. self.validate_schema(request, response)