test_organization_sessions.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import pytest
  2. from django.test.client import RequestFactory
  3. from django.urls import reverse
  4. from fixtures.apidocs_test_case import APIDocsTestCase
  5. from sentry.testutils.cases import SnubaTestCase
  6. pytestmark = pytest.mark.sentry_metrics
  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_id_or_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)