mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-28 09:16:49 +01:00
165ffcaffb
* Instrument legacy endpoint debugging * Add `currentTeamId` to `teamLogic` * Add logics utils * Update annotations endpoint in the frontend * Limit legacy endpoint logging to DEBUG * Fix `annotationsTableLogic` usage * Update test_annotation.py * Add `test_deleting_annotation_of_other_team_prevented` * Comment out debug code * Migrate actions-related code to project-based approach * Fix `infiniteTestLogic` * Rework approach * Remove redundant lines * Fix mixup * Fix non-logged-in scenes * Fix Python cast * Align approach to `teamLogic`-based * Fix logic tests * Clean up code * Fix stupid omission * Restore `props` in `connect`s * Fix capitalization * Fix action creation * Fix `ActionEdit` props type * Migrate events-related code to project-based approach * Remove `MOCK_ORGANIZATION_ID` * Update sessionsPlayLogic.test.ts * Fix logic tests * Fix duplicate imports * Reduce duplication in URL test instrumentation * Update API interception paths in tests * Fix `Person.cy-spec.js` * Add comments in `posthog/api/__init__.py` * reduce test noise * Update infiniteListLogic.ts * Simplify `teamLogic` seeding * Simplify `teamLogic` seeding better * Fix `organizationLogic` tests * Migrate feature flags-related logics to be project-based (#6603) * Migrate feature flags-related logics to be project-based * Add comment * Migrate insight-related logics to be project-based (#6574) * Migrate insight-related logics to be project-based * Migrate over the rest and fix logic tests * Update funnelLogic.ts * Fix URL formatting in tests * Update dashboardLogic.tsx * Remove now redundant `initTeamLogic` * Add tracking comments Co-authored-by: Marius Andra <marius.andra@gmail.com>
25 lines
1.0 KiB
Python
25 lines
1.0 KiB
Python
import json
|
||
|
||
from ee.api.test.base import APILicensedTest
|
||
from posthog.models import User
|
||
|
||
|
||
class TestQueryMiddleware(APILicensedTest):
|
||
def test_query(self):
|
||
self.user.is_staff = True
|
||
self.user.save()
|
||
response = self.client.get(
|
||
f'/api/projects/{self.team.id}/insights/trend/?events={json.dumps([{"id": "$pageview"}])}'
|
||
)
|
||
self.assertEqual(response.status_code, 200)
|
||
response = self.client.get("/api/debug_ch_queries/").json()
|
||
self.assertIn("SELECT", response[0]["query"]) # type: ignore
|
||
|
||
# Test saving queries if we're impersonating a user
|
||
user2 = User.objects.create_and_join(organization=self.organization, email="test", password="bla")
|
||
self.client.post("/admin/login/user/{}/".format(user2.pk))
|
||
self.client.get(f'/api/projects/{self.team.id}/insights/trend/?events={json.dumps([{"id": "$pageleave"}])}')
|
||
|
||
response = self.client.get("/api/debug_ch_queries/").json()
|
||
self.assertIn("SELECT", response[0]["query"]) # type: ignore
|