test_service_hooks.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. from django.test.client import RequestFactory
  2. from django.urls import reverse
  3. from fixtures.apidocs_test_case import APIDocsTestCase
  4. class ProjectServiceHooksDocs(APIDocsTestCase):
  5. def setUp(self):
  6. self.create_service_hook(project=self.project, events=("event.created",))
  7. self.create_service_hook(project=self.project, events=("event.alert",))
  8. self.url = reverse(
  9. "sentry-api-0-service-hooks",
  10. kwargs={"organization_slug": self.organization.slug, "project_slug": self.project.slug},
  11. )
  12. self.login_as(user=self.user)
  13. def test_get(self):
  14. with self.feature("projects:servicehooks"):
  15. response = self.client.get(self.url)
  16. request = RequestFactory().get(self.url)
  17. self.validate_schema(request, response)
  18. def test_post(self):
  19. data = {"url": "https://example.com/other-sentry-hook", "events": ["event.created"]}
  20. with self.feature("projects:servicehooks"):
  21. response = self.client.post(self.url, data)
  22. request = RequestFactory().post(self.url, data)
  23. self.validate_schema(request, response)