test_project_release_commits.py 1.6 KB

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