test_organization_release_details.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from datetime import 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, version="1", date_added=datetime(2013, 8, 13, 3, 8, 24, 880386)
  23. )
  24. self.url = reverse(
  25. "sentry-api-0-organization-release-details",
  26. kwargs={"organization_slug": org.slug, "version": release.version},
  27. )
  28. def test_get(self):
  29. response = self.client.get(self.url)
  30. request = RequestFactory().get(self.url)
  31. self.validate_schema(request, response)
  32. def test_put(self):
  33. data = {"projects": [self.project3.slug]}
  34. response = self.client.put(self.url, data)
  35. request = RequestFactory().put(self.url, data)
  36. self.validate_schema(request, response)