test_organization_release_commits.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 ReleaseCommitsListDocsTest(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-organization-release-commits",
  25. kwargs={"organization_slug": project.organization.slug, "version": release.version},
  26. )
  27. self.login_as(user=self.user)
  28. def test_get(self):
  29. response = self.client.get(self.url)
  30. request = RequestFactory().get(self.url)
  31. self.validate_schema(request, response)