test_installation_install_event.py 928 B

123456789101112131415161718192021222324252627
  1. from uuid import uuid4
  2. from sentry.models.integrations.integration import Integration
  3. from sentry.testutils.cases import APITestCase
  4. from sentry.testutils.silo import control_silo_test
  5. from sentry_plugins.github.testutils import INSTALLATION_EVENT_EXAMPLE
  6. @control_silo_test
  7. class InstallationInstallEventWebhookTest(APITestCase):
  8. def test_simple(self):
  9. url = "/plugins/github/installations/webhook/"
  10. response = self.client.post(
  11. path=url,
  12. data=INSTALLATION_EVENT_EXAMPLE,
  13. content_type="application/json",
  14. HTTP_X_GITHUB_EVENT="installation",
  15. HTTP_X_HUB_SIGNATURE="sha1=348e46312df2901e8cb945616ee84ce30d9987c9",
  16. HTTP_X_GITHUB_DELIVERY=str(uuid4()),
  17. )
  18. assert response.status_code == 204
  19. assert Integration.objects.filter(
  20. provider="github_apps", external_id=2, name="octocat"
  21. ).exists()