test_project_release_commits.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from django.test.client import RequestFactory
  2. from django.urls import reverse
  3. from fixtures.apidocs_test_case import APIDocsTestCase
  4. from sentry.models import Commit, ReleaseCommit
  5. from sentry.testutils.silo import region_silo_test
  6. @region_silo_test
  7. class ProjectReleaseCommitsListDocsTest(APIDocsTestCase):
  8. def setUp(self):
  9. project = self.create_project(name="foo")
  10. release = self.create_release(project=project, version="1")
  11. release.add_project(project)
  12. repo = self.create_repo(project=project, name=project.name)
  13. commit = Commit.objects.create(
  14. organization_id=project.organization_id, repository_id=repo.id, key="a" * 40
  15. )
  16. commit2 = Commit.objects.create(
  17. organization_id=project.organization_id, repository_id=repo.id, key="b" * 40
  18. )
  19. ReleaseCommit.objects.create(
  20. organization_id=project.organization_id, release=release, commit=commit, order=1
  21. )
  22. ReleaseCommit.objects.create(
  23. organization_id=project.organization_id, release=release, commit=commit2, order=0
  24. )
  25. self.url = reverse(
  26. "sentry-api-0-project-release-commits",
  27. kwargs={
  28. "organization_slug": project.organization.slug,
  29. "project_slug": project.slug,
  30. "version": release.version,
  31. },
  32. )
  33. self.login_as(user=self.user)
  34. def test_get(self):
  35. response = self.client.get(self.url)
  36. request = RequestFactory().get(self.url)
  37. self.validate_schema(request, response)