test_organization_release_commit_files.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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, CommitFileChange, ReleaseCommit
  5. class CommitFileChangeDocsTest(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. CommitFileChange.objects.create(
  24. organization_id=project.organization_id, commit=commit, filename=".gitignore", type="M"
  25. )
  26. CommitFileChange.objects.create(
  27. organization_id=project.organization_id,
  28. commit=commit2,
  29. filename="/static/js/widget.js",
  30. type="A",
  31. )
  32. self.url = reverse(
  33. "sentry-api-0-release-commitfilechange",
  34. kwargs={"organization_slug": project.organization.slug, "version": release.version},
  35. )
  36. self.login_as(user=self.user)
  37. def test_get(self):
  38. response = self.client.get(self.url)
  39. request = RequestFactory().get(self.url)
  40. self.validate_schema(request, response)