test_project_issues_solved_in_release.py 2.6 KB

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