test_organization_sessions.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from django.test.client import RequestFactory
  2. from django.urls import reverse
  3. from fixtures.apidocs_test_case import APIDocsTestCase
  4. from sentry.testutils.cases import SnubaTestCase
  5. from sentry.testutils.silo import region_silo_test
  6. @region_silo_test
  7. class OrganizationSessionsDocsTest(APIDocsTestCase, SnubaTestCase):
  8. def setUp(self):
  9. super().setUp()
  10. self.organization = self.create_organization(owner=self.user, name="foo")
  11. self.project = self.create_project(name="bar", organization=self.organization, teams=[])
  12. self.url = reverse(
  13. "sentry-api-0-organization-sessions",
  14. kwargs={"organization_slug": self.organization.slug},
  15. )
  16. self.login_as(user=self.user)
  17. def test_get(self):
  18. query = {
  19. "project": [self.project.id],
  20. "statsPeriod": "30d",
  21. "field": ["sum(session)"],
  22. "groupBy": ["release"],
  23. }
  24. request = RequestFactory().get(self.url)
  25. response = self.client.get(self.url, query)
  26. assert response.status_code == 200, response.content
  27. self.validate_schema(request, response)