test_project_issues_solved_in_release.py 2.4 KB

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