test_organization_release_commit_files.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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.commitfilechange import CommitFileChange
  6. from sentry.models.releasecommit import ReleaseCommit
  7. class CommitFileChangeDocsTest(APIDocsTestCase):
  8. def setUp(self):
  9. project = self.create_project(name="foo")
  10. release = self.create_release(project=project, version="1")
  11. release.add_project(project)
  12. repo = self.create_repo(project=project, name=project.name)
  13. commit = Commit.objects.create(
  14. organization_id=project.organization_id, repository_id=repo.id, key="a" * 40
  15. )
  16. commit2 = Commit.objects.create(
  17. organization_id=project.organization_id, repository_id=repo.id, key="b" * 40
  18. )
  19. ReleaseCommit.objects.create(
  20. organization_id=project.organization_id, release=release, commit=commit, order=1
  21. )
  22. ReleaseCommit.objects.create(
  23. organization_id=project.organization_id, release=release, commit=commit2, order=0
  24. )
  25. CommitFileChange.objects.create(
  26. organization_id=project.organization_id, commit=commit, filename=".gitignore", type="M"
  27. )
  28. CommitFileChange.objects.create(
  29. organization_id=project.organization_id,
  30. commit=commit2,
  31. filename="/static/js/widget.js",
  32. type="A",
  33. )
  34. self.url = reverse(
  35. "sentry-api-0-release-commitfilechange",
  36. kwargs={"organization_slug": project.organization.slug, "version": release.version},
  37. )
  38. self.login_as(user=self.user)
  39. def test_get(self):
  40. response = self.client.get(self.url)
  41. request = RequestFactory().get(self.url)
  42. self.validate_schema(request, response)