: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(flags): use PushGatewayTaskTestMixin in the feature flag metrics tests (#121753)
Phil Haack0d623cf78c51
diff --git a/products/feature_flags/backend/test/test_feature_flag_metrics.py b/products/feature_flags/backend/test/test_feature_flag_metrics.pyindex d0f188319210..7fde6ad5242a 100644--- a/products/feature_flags/backend/test/test_feature_flag_metrics.py+++ b/products/feature_flags/backend/test/test_feature_flag_metrics.py@@ -1,24 +1,17 @@from posthog.test.base import BaseTest-from unittest.mock import MagicMock, patch--from prometheus_client import CollectorRegistry+from unittest.mock import patchfrom posthog.models import Teamfrom posthog.models.organization import Organization+from posthog.tasks.test.utils import PushGatewayTaskTestMixinfrom products.feature_flags.backend.models.feature_flag import FeatureFlagfrom products.feature_flags.backend.tasks import compute_feature_flag_metrics-class TestComputeFeatureFlagMetrics(BaseTest):+class TestComputeFeatureFlagMetrics(PushGatewayTaskTestMixin, BaseTest):def setUp(self) -> None:super().setUp()- self.registry = CollectorRegistry()- self.mock_context = MagicMock()- self.mock_context.__enter__ = MagicMock(return_value=self.registry)- self.mock_context.__exit__ = MagicMock(return_value=False)- self.patcher = patch("posthog.tasks.utils.pushed_metrics_registry", return_value=self.mock_context)- self.patcher.start()self.settings_patcher = patch("products.feature_flags.backend.tasks.settings.PROM_PUSHGATEWAY_ADDRESS", "http://localhost:9091")@@ -26,7 +19,6 @@ class TestComputeFeatureFlagMetrics(BaseTest):def tearDown(self) -> None:self.settings_patcher.stop()- self.patcher.stop()super().tearDown()def test_computes_metrics_for_single_team(self) -> None: