test_organization_releases.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.models import Release
  6. from sentry.testutils.silo import region_silo_test
  7. @region_silo_test
  8. class OrganizationReleasesDocsTest(APIDocsTestCase):
  9. def setUp(self):
  10. user = self.create_user(is_staff=False, is_superuser=False)
  11. org = self.create_organization(owner=user, name="blah")
  12. org2 = self.create_organization(owner=user, name="bloop")
  13. team1 = self.create_team(organization=org)
  14. team2 = self.create_team(organization=org)
  15. self.create_team_membership(team1, user=user)
  16. self.create_team_membership(team2, user=user)
  17. self.project1 = self.create_project(teams=[team1], organization=org)
  18. self.project2 = self.create_project(teams=[team2], organization=org2)
  19. self.project3 = self.create_project(teams=[team1], organization=org)
  20. self.login_as(user=user)
  21. release1 = Release.objects.create(
  22. organization_id=org.id, version="1", date_added=datetime(2013, 8, 13, 3, 8, 24, 880386)
  23. )
  24. release1.add_project(self.project1)
  25. release2 = Release.objects.create(
  26. organization_id=org2.id, version="2", date_added=datetime(2013, 8, 14, 3, 8, 24, 880386)
  27. )
  28. release2.add_project(self.project2)
  29. self.url = reverse(
  30. "sentry-api-0-organization-releases", kwargs={"organization_slug": org.slug}
  31. )
  32. def test_get(self):
  33. response = self.client.get(self.url)
  34. request = RequestFactory().get(self.url)
  35. self.validate_schema(request, response)
  36. def test_post(self):
  37. data = {"version": "1.2.1", "projects": [self.project3.slug]}
  38. response = self.client.post(self.url, data)
  39. request = RequestFactory().post(self.url, data)
  40. self.validate_schema(request, response)