test_organization_releases.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. from sentry.models.release 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.create_team_membership(team1, user=user)
  14. self.create_team_membership(team2, user=user)
  15. self.project1 = self.create_project(teams=[team1], organization=org)
  16. self.project2 = self.create_project(teams=[team2], organization=org2)
  17. self.project3 = self.create_project(teams=[team1], organization=org)
  18. self.login_as(user=user)
  19. release1 = Release.objects.create(
  20. organization_id=org.id,
  21. version="1",
  22. date_added=datetime(2013, 8, 13, 3, 8, 24, 880386, tzinfo=UTC),
  23. )
  24. release1.add_project(self.project1)
  25. release2 = Release.objects.create(
  26. organization_id=org2.id,
  27. version="2",
  28. date_added=datetime(2013, 8, 14, 3, 8, 24, 880386, tzinfo=UTC),
  29. )
  30. release2.add_project(self.project2)
  31. self.url = reverse(
  32. "sentry-api-0-organization-releases", kwargs={"organization_slug": org.slug}
  33. )
  34. def test_get(self):
  35. response = self.client.get(self.url)
  36. request = RequestFactory().get(self.url)
  37. self.validate_schema(request, response)
  38. def test_post(self):
  39. data = {"version": "1.2.1", "projects": [self.project3.slug]}
  40. response = self.client.post(self.url, data)
  41. request = RequestFactory().post(self.url, data)
  42. self.validate_schema(request, response)