test_organization_release_details.py 1.6 KB

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