test_organization_release_commit_files.py 1.8 KB

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