test_organization_release_details.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. class OrganizationReleaseDetailsDocsTest(APIDocsTestCase):
  6. def setUp(self):
  7. user = self.create_user(is_staff=False, is_superuser=False)
  8. org = self.organization
  9. org2 = self.create_organization()
  10. org.flags.allow_joinleave = False
  11. org.save()
  12. team1 = self.create_team(organization=org)
  13. team2 = self.create_team(organization=org)
  14. self.project1 = self.create_project(teams=[team1], organization=org)
  15. self.project2 = self.create_project(teams=[team2], organization=org2)
  16. self.project3 = self.create_project(teams=[team1], organization=org)
  17. self.create_member(teams=[team1], user=user, organization=org)
  18. self.login_as(user=user)
  19. release = self.create_release(
  20. project=self.project1,
  21. version="1",
  22. date_added=datetime(2013, 8, 13, 3, 8, 24, 880386, tzinfo=UTC),
  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)