test_organization_sessions.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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 import SnubaTestCase
  5. class OrganizationSessionsDocsTest(APIDocsTestCase, SnubaTestCase):
  6. def setUp(self):
  7. super().setUp()
  8. self.organization = self.create_organization(owner=self.user, name="foo")
  9. self.project = self.create_project(name="bar", organization=self.organization, teams=[])
  10. self.url = reverse(
  11. "sentry-api-0-organization-sessions",
  12. kwargs={"organization_slug": self.organization.slug},
  13. )
  14. self.login_as(user=self.user)
  15. def test_get(self):
  16. query = {
  17. "project": [self.project.id],
  18. "statsPeriod": "30d",
  19. "field": ["sum(session)"],
  20. "groupBy": ["release"],
  21. }
  22. request = RequestFactory().get(self.url)
  23. response = self.client.get(self.url, query)
  24. assert response.status_code == 200, response.content
  25. self.validate_schema(request, response)