test_organization_release_details.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from datetime import UTC, datetime
  2. from django.test.client import RequestFactory
  3. from django.urls import reverse
  4. from fixtures.apidocs_test_case import APIDocsTestCase
  5. from sentry.testutils.silo import region_silo_test
  6. @region_silo_test
  7. class OrganizationReleaseDetailsDocsTest(APIDocsTestCase):
  8. def setUp(self):
  9. user = self.create_user(is_staff=False, is_superuser=False)
  10. org = self.organization
  11. org2 = self.create_organization()
  12. org.flags.allow_joinleave = False
  13. org.save()
  14. team1 = self.create_team(organization=org)
  15. team2 = self.create_team(organization=org)
  16. self.project1 = self.create_project(teams=[team1], organization=org)
  17. self.project2 = self.create_project(teams=[team2], organization=org2)
  18. self.project3 = self.create_project(teams=[team1], organization=org)
  19. self.create_member(teams=[team1], user=user, organization=org)
  20. self.login_as(user=user)
  21. release = self.create_release(
  22. project=self.project1,
  23. version="1",
  24. date_added=datetime(2013, 8, 13, 3, 8, 24, 880386, tzinfo=UTC),
  25. )
  26. self.url = reverse(
  27. "sentry-api-0-organization-release-details",
  28. kwargs={"organization_slug": org.slug, "version": release.version},
  29. )
  30. def test_get(self):
  31. response = self.client.get(self.url)
  32. request = RequestFactory().get(self.url)
  33. self.validate_schema(request, response)
  34. def test_put(self):
  35. data = {"projects": [self.project3.slug]}
  36. response = self.client.put(self.url, data)
  37. request = RequestFactory().put(self.url, data)
  38. self.validate_schema(request, response)