test_project_release_commits.py 1.5 KB

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