0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 18:26:15 +01:00
posthog/ee/api/test/test_debug_ch_queries.py
2022-10-19 08:58:36 +02:00

31 lines
1.1 KiB
Python

from unittest.mock import patch
from rest_framework.status import HTTP_200_OK, HTTP_403_FORBIDDEN
from posthog.test.base import APIBaseTest
class TestProjectEnterpriseAPI(APIBaseTest):
CLASS_DATA_LEVEL_SETUP = False
def test_denied(self):
with patch("ee.api.debug_ch_queries.is_cloud", return_value=True):
with patch("ee.api.debug_ch_queries.DEBUG", True):
resp = self.client.get("/api/debug_ch_queries/")
self.assertEqual(resp.status_code, HTTP_200_OK)
with patch("ee.api.debug_ch_queries.DEBUG", False):
resp = self.client.get("/api/debug_ch_queries/")
self.assertEqual(resp.status_code, HTTP_403_FORBIDDEN)
self.user.is_staff = True
self.user.save()
resp = self.client.get("/api/debug_ch_queries/")
self.assertEqual(resp.status_code, HTTP_200_OK)
with patch("ee.api.debug_ch_queries.is_cloud", return_value=False):
resp = self.client.get("/api/debug_ch_queries/")
self.assertEqual(resp.status_code, HTTP_200_OK)