test_service_hook_details.py 1.1 KB

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