Skip to content

: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.

chore(tests): avoid database setup in auth, billing, and related tests (part 2) (#116238)

Paul D'Ambraf7a60dd0c7aa
diff --git a/posthog/tasks/test/test_auth_token_cache_verification.py b/posthog/tasks/test/test_auth_token_cache_verification.py
index 014cae195ec5..04e2fd812072 100644
--- a/posthog/tasks/test/test_auth_token_cache_verification.py
+++ b/posthog/tasks/test/test_auth_token_cache_verification.py
@@ -1,6 +1,6 @@
from unittest.mock import MagicMock, patch
-from django.test import TestCase, override_settings
+from django.test import SimpleTestCase, override_settings
from posthog.storage.auth_token_cache_verifier import AuthTokenVerificationResult
from posthog.tasks.auth_token_cache_verification import LOCK_KEY, verify_and_fix_auth_token_cache_task
@@ -8,7 +8,7 @@ from posthog.tasks.test.utils import PushGatewayTaskTestMixin
@override_settings(FLAGS_REDIS_URL="redis://test")
-class TestVerifyAndFixAuthTokenCacheTask(PushGatewayTaskTestMixin, TestCase):
+class TestVerifyAndFixAuthTokenCacheTask(PushGatewayTaskTestMixin, SimpleTestCase):
@patch("posthog.storage.auth_token_cache_verifier.verify_and_fix_auth_token_cache")
@patch("posthog.redis.get_client")
def test_runs_verification(self, mock_get_client: MagicMock, mock_verify: MagicMock) -> None:
@@ -90,7 +90,7 @@ class TestVerifyAndFixAuthTokenCacheTask(PushGatewayTaskTestMixin, TestCase):
@override_settings(FLAGS_REDIS_URL=None)
-class TestVerifyAndFixAuthTokenCacheTaskDisabled(TestCase):
+class TestVerifyAndFixAuthTokenCacheTaskDisabled(SimpleTestCase):
@patch("posthog.redis.get_client")
def test_skips_when_no_redis_url(self, mock_get_client: MagicMock) -> None:
verify_and_fix_auth_token_cache_task()
diff --git a/posthog/temporal/proxy_service/test/monitor_test.py b/posthog/temporal/proxy_service/test/monitor_test.py
index f008eedd45c8..0426960d6a01 100644
--- a/posthog/temporal/proxy_service/test/monitor_test.py
+++ b/posthog/temporal/proxy_service/test/monitor_test.py
@@ -5,7 +5,7 @@ import pytest
import time_machine
from unittest.mock import MagicMock, Mock, patch
-from django.test import TestCase
+from django.test import SimpleTestCase, TestCase
import requests
from parameterized import parameterized
@@ -293,7 +293,7 @@ def _hostname(status: CustomHostnameStatus, ssl_status=CustomHostnameSSLStatus.A
)
-class TestCheckCloudflareCertificateStatus(TestCase):
+class TestCheckCloudflareCertificateStatus(SimpleTestCase):
@parameterized.expand(
[
("blocked", CustomHostnameStatus.BLOCKED),
diff --git a/posthog/temporal/proxy_service/test/test_cloudflare.py b/posthog/temporal/proxy_service/test/test_cloudflare.py
index 9955a257a2df..846d5952c7a1 100644
--- a/posthog/temporal/proxy_service/test/test_cloudflare.py
+++ b/posthog/temporal/proxy_service/test/test_cloudflare.py
@@ -1,6 +1,6 @@
from unittest.mock import Mock, patch
-from django.test import SimpleTestCase, TestCase, override_settings
+from django.test import SimpleTestCase, override_settings
from parameterized import parameterized
@@ -63,7 +63,7 @@ CLOUDFLARE_HOSTNAME_STATUSES = [
]
-class TestCloudflareAPIErrorIsRateLimited(TestCase):
+class TestCloudflareAPIErrorIsRateLimited(SimpleTestCase):
@parameterized.expand(
[
("error_code_10000", "Rate limited", [{"code": 10000}], True),
diff --git a/posthog/test/repo_invariants/database_free_test_classes_baseline.txt b/posthog/test/repo_invariants/database_free_test_classes_baseline.txt
index 242f6f53e577..4a7bdc7ef82f 100644
--- a/posthog/test/repo_invariants/database_free_test_classes_baseline.txt
+++ b/posthog/test/repo_invariants/database_free_test_classes_baseline.txt
@@ -13,16 +13,11 @@ posthog/hogql/printer/test/test_sql_injection_defenses.py::TestVerbatimFieldPrin
posthog/models/tophog/test/test_tophog_queries.py::TestTopHogQueries
posthog/session_recordings/test/test_session_recording_throttle.py::TestSharingTokenReplayThrottle
posthog/session_recordings/test/test_session_recording_throttle.py::TestTierAwareListingThrottle
-posthog/tasks/test/test_auth_token_cache_verification.py::TestVerifyAndFixAuthTokenCacheTask
-posthog/tasks/test/test_auth_token_cache_verification.py::TestVerifyAndFixAuthTokenCacheTaskDisabled
posthog/tasks/test/test_usage_report.py::TestSendNoUsage
-posthog/temporal/proxy_service/test/monitor_test.py::TestCheckCloudflareCertificateStatus
-posthog/temporal/proxy_service/test/test_cloudflare.py::TestCloudflareAPIErrorIsRateLimited
posthog/test/activity_logging/test_feature_flag_activity_logging.py::TestChangesBetweenFeatureFlags
posthog/test/test_api_queries_budget.py::TestTokenBucket
posthog/test/test_check_product_migrations.py::TestCheckProductMigrations
products/alerts/backend/tests/api/test_alert.py::TestAlertEventProperties
-products/conversations/backend/api/tests/test_teams_token_storage.py::TestTrustedTeamsServiceUrl
products/data_modeling/backend/test/test_saved_query_dag_sync.py::TestGetDagId
products/posthog_ai/eval_harness/test/test_acp_log.py::TestSandboxedTraceCaptureParser
products/posthog_ai/scripts/hogql_example/test/test_hogql_example.py::TestRenderHogQLExample
diff --git a/products/conversations/backend/api/tests/test_teams_token_storage.py b/products/conversations/backend/api/tests/test_teams_token_storage.py
index 128314746c93..7ffcbef8493e 100644
--- a/products/conversations/backend/api/tests/test_teams_token_storage.py
+++ b/products/conversations/backend/api/tests/test_teams_token_storage.py
@@ -1,6 +1,7 @@
from posthog.test.base import BaseTest
from django.db import connection
+from django.test import SimpleTestCase
from parameterized import parameterized
@@ -201,7 +202,7 @@ class TestTeamsTokenStorage(BaseTest):
get_graph_token(self.team)
-class TestTrustedTeamsServiceUrl(BaseTest):
+class TestTrustedTeamsServiceUrl(SimpleTestCase):
@parameterized.expand(
[
("https://smba.trafficmanager.net/teams/",),