test_organization_releases.py 1.7 KB

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