test_organization_release_commits.py 1.5 KB

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