:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(tests): reduce database-backed test baseline (#117564)
Paul D'Ambraf39c287ccb71
diff --git a/posthog/api/oauth/test_cimd.py b/posthog/api/oauth/test_cimd.pyindex 5b04e5b0e925..b8cd16e0aa4e 100644--- a/posthog/api/oauth/test_cimd.py+++ b/posthog/api/oauth/test_cimd.py@@ -15,7 +15,6 @@ from django.utils.html import escapeimport requestsfrom parameterized import parameterized-from rest_framework.test import APIClientfrom posthog.api.oauth.cimd import (CIMDFetchError,@@ -1044,15 +1043,6 @@ class TestCIMDVerificationRejectedCaptureEvent(APIBaseTest):self.assertEqual(rejected[0].kwargs["properties"]["reason"], "app_url_missing")-class TestAuthorizationServerMetadata(APIBaseTest):- def test_advertises_cimd_support(self):- client = APIClient()- response = client.get("/.well-known/oauth-authorization-server")- self.assertEqual(response.status_code, 200)- data = response.json()- self.assertTrue(data.get("client_id_metadata_document_supported"))--@patch("posthog.security.url_validation.resolve_host_ips", return_value={ip_address("93.184.216.34")})class TestCIMDAuthorizeIntegration(APIBaseTest):"""Integration tests for the CIMD flow through /oauth/authorize/."""diff --git a/posthog/api/oauth/test_views.py b/posthog/api/oauth/test_views.pyindex c7e284b96daa..f561fcd2926a 100644--- a/posthog/api/oauth/test_views.py+++ b/posthog/api/oauth/test_views.py@@ -5743,6 +5743,7 @@ class TestOAuthAuthorizationServerMetadata(APIBaseTest):response = self.client.get("/.well-known/oauth-authorization-server")self.assertEqual(response.status_code, status.HTTP_200_OK)+ self.assertTrue(response.json()["client_id_metadata_document_supported"])@override_settings(CLOUD_DEPLOYMENT="US", SITE_URL="https://us.posthog.com")def test_metadata_includes_region_for_cloud(self):diff --git a/posthog/test/repo_invariants/database_free_test_classes_baseline.txt b/posthog/test/repo_invariants/database_free_test_classes_baseline.txtindex 773d78008b60..b74aed525f74 100644--- a/posthog/test/repo_invariants/database_free_test_classes_baseline.txt+++ b/posthog/test/repo_invariants/database_free_test_classes_baseline.txt@@ -1,6 +1,5 @@ee/clickhouse/models/test/test_dead_letter_queue.py::TestDeadLetterQueueee/clickhouse/models/test/test_property.py::TestPropDenormalized-posthog/api/oauth/test_cimd.py::TestAuthorizationServerMetadataposthog/clickhouse/test/test_deletion_coverage.py::TestDeletionCoverageposthog/hogql/database/test/test_postgres_table.py::TestPostgresTablePrimaryKeyposthog/hogql/printer/test/test_sql_injection_defenses.py::TestEscapePreservationOnParserOutput@@ -13,7 +12,6 @@ posthog/test/test_check_product_migrations.py::TestCheckProductMigrationsproducts/posthog_ai/scripts/hogql_example/test/test_hogql_example.py::TestRenderHogQLExampleproducts/streamlit_apps/backend/tests/test_tasks.py::TestAutoRestartCrashedStreamlitSandboxesproducts/streamlit_apps/backend/tests/test_tasks.py::TestStopIdleStreamlitSandboxes-products/surveys/backend/api/test/test_external_surveys.py::TestExternalSurveysURLsproducts/web_analytics/dags/tests/test_cache_warming.py::TestFleetQuerySelectionproducts/web_analytics/dags/tests/test_cache_warming.py::TestSplitWarmableQueriesproducts/web_analytics/dags/tests/test_cache_warming.py::TestWarmableQueriesCachingdiff --git a/products/surveys/backend/api/test/test_external_surveys.py b/products/surveys/backend/api/test/test_external_surveys.pyindex 3b258b2c1aa3..d554f0a0f60d 100644--- a/products/surveys/backend/api/test/test_external_surveys.py+++ b/products/surveys/backend/api/test/test_external_surveys.py@@ -5,10 +5,10 @@ from datetime import UTC, datetime, timedeltafrom urllib.parse import parse_qslfrom posthog.test.base import APIBaseTest-from unittest.mock import patch+from unittest.mock import MagicMock, patchfrom django.core.cache import cache-from django.test import TestCase, override_settings+from django.test import SimpleTestCase, override_settingsfrom parameterized import parameterized@@ -509,17 +509,17 @@ class TestExternalSurveys(APIBaseTest):assert response.status_code == 200-class TestExternalSurveysURLs(TestCase):+class TestExternalSurveysURLs(SimpleTestCase):"""Test URL routing for external surveys"""- def test_survey_url_pattern(self):+ @patch("products.surveys.backend.api.survey.Survey.objects.select_related")+ def test_survey_url_pattern(self, mock_select_related: MagicMock) -> None:"""Test that survey URLs are properly routed"""- from django.test import Client-survey_id = str(uuid.uuid4())- client = Client()+ mock_select_related.return_value.get.side_effect = Survey.DoesNotExist# Test that the URL pattern matches correctly (should return 404 for non-existent survey)- response = client.get(f"/external_surveys/{survey_id}/")+ response = self.client.get(f"/external_surveys/{survey_id}/")# We expect 404 since survey doesn't exist, but URL should be routed correctlyassert response.status_code == 404+ assert "Survey not available" in response.content.decode()