test_project_release_commits.py 1.6 KB

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