test_project_issues_solved_in_release.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from uuid import uuid1
  2. from django.test.client import RequestFactory
  3. from django.urls import reverse
  4. from fixtures.apidocs_test_case import APIDocsTestCase
  5. from sentry.models import Commit, GroupLink, GroupResolution, ReleaseCommit, Repository
  6. class ProjectIssuesResolvedInReleaseEndpointTest(APIDocsTestCase):
  7. endpoint = "sentry-api-0-project-release-resolved"
  8. method = "get"
  9. def setUp(self):
  10. super().setUp()
  11. self.user = self.create_user()
  12. self.org = self.create_organization()
  13. self.team = self.create_team(organization=self.org)
  14. self.create_member(organization=self.org, user=self.user, teams=[self.team])
  15. self.project = self.create_project(teams=[self.team])
  16. self.release = self.create_release(project=self.project)
  17. self.group = self.create_group(project=self.project)
  18. self.login_as(self.user)
  19. repo = Repository.objects.create(organization_id=self.org.id, name=self.project.name)
  20. commit = Commit.objects.create(
  21. organization_id=self.org.id, repository_id=repo.id, key=uuid1().hex
  22. )
  23. commit2 = Commit.objects.create(
  24. organization_id=self.org.id, repository_id=repo.id, key=uuid1().hex
  25. )
  26. ReleaseCommit.objects.create(
  27. organization_id=self.org.id, release=self.release, commit=commit, order=1
  28. )
  29. ReleaseCommit.objects.create(
  30. organization_id=self.org.id, release=self.release, commit=commit2, order=0
  31. )
  32. GroupLink.objects.create(
  33. group_id=self.group.id,
  34. project_id=self.group.project_id,
  35. linked_type=GroupLink.LinkedType.commit,
  36. relationship=GroupLink.Relationship.resolves,
  37. linked_id=commit.id,
  38. )
  39. GroupResolution.objects.create(
  40. group=self.group,
  41. release=self.release,
  42. type=GroupResolution.Type.in_release,
  43. )
  44. self.url = reverse(
  45. "sentry-api-0-project-release-resolved",
  46. kwargs={
  47. "organization_slug": self.project.organization.slug,
  48. "project_slug": self.project.slug,
  49. "version": self.release.version,
  50. },
  51. )
  52. def test_get(self):
  53. response = self.client.get(self.url)
  54. request = RequestFactory().get(self.url)
  55. self.validate_schema(request, response)