: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(ci): use real source contracts in schema refresh tests (#129784)
posthog[bot]45574b67f90c
diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_source.py b/products/warehouse_sources/backend/tests/api/test_external_data_source.pyindex 386f5b4c1a8b..cf1201cac92a 100644--- a/products/warehouse_sources/backend/tests/api/test_external_data_source.py+++ b/products/warehouse_sources/backend/tests/api/test_external_data_source.py@@ -3880,19 +3880,9 @@ class TestExternalDataSource(APIBaseTest):self.assertEqual(response.status_code, 200)self.assertEqual(source.status, "Running")- @patch("products.warehouse_sources.backend.presentation.views.external_data_source.base.SourceRegistry.get_source")- def test_refresh_schemas_creates_new_schemas_and_returns_counts(self, mock_get_source):- parsed_config = Mock(spec=["to_dict"])- parsed_config.to_dict.return_value = {- "host": "localhost",- "port": "5432",- "database": "database",- "user": "user",- "password": "password",- "schema": "analytics",- }- mock_get_source.return_value.parse_config.return_value = parsed_config- mock_get_source.return_value.get_schemas.return_value = [+ @patch.object(StripeSource, "get_schemas")+ def test_refresh_schemas_creates_new_schemas_and_returns_counts(self, mock_get_schemas):+ mock_get_schemas.return_value = [SourceSchema(name="table_a", supports_incremental=False, supports_append=False),SourceSchema(name="table_b", supports_incremental=False, supports_append=False),]@@ -3952,10 +3942,9 @@ class TestExternalDataSource(APIBaseTest):assert schema.should_sync is False@patch("products.data_warehouse.backend.facade.api.sync_external_data_job_workflow")- @patch("products.warehouse_sources.backend.presentation.views.external_data_source.base.SourceRegistry.get_source")- def test_refresh_schemas_auto_enables_matching_new_schemas(self, mock_get_source, mock_schedule):- mock_get_source.return_value.parse_config.return_value = None- mock_get_source.return_value.get_schemas.return_value = [+ @patch.object(StripeSource, "get_schemas")+ def test_refresh_schemas_auto_enables_matching_new_schemas(self, mock_get_schemas, mock_schedule):+ mock_get_schemas.return_value = [SourceSchema(name="raw_events",supports_incremental=True,@@ -4035,10 +4024,9 @@ class TestExternalDataSource(APIBaseTest):source.refresh_from_db()self.assertFalse(source.auto_sync_new_schemas)- @patch("products.warehouse_sources.backend.presentation.views.external_data_source.base.SourceRegistry.get_source")- def test_refresh_schemas_creates_new_schemas_and_deletes_missing_schemas(self, mock_get_source):- mock_get_source.return_value.parse_config.return_value = None- mock_get_source.return_value.get_schemas.return_value = [+ @patch.object(StripeSource, "get_schemas")+ def test_refresh_schemas_creates_new_schemas_and_deletes_missing_schemas(self, mock_get_schemas):+ mock_get_schemas.return_value = [SourceSchema(name="new_table", supports_incremental=False, supports_append=False),]source = self._create_external_data_source()@@ -4065,10 +4053,9 @@ class TestExternalDataSource(APIBaseTest):)self.assertCountEqual(names, ["new_table"])- @patch("products.warehouse_sources.backend.presentation.views.external_data_source.base.SourceRegistry.get_source")- def test_refresh_schemas_adds_only_new_schemas(self, mock_get_source):- mock_get_source.return_value.parse_config.return_value = None- mock_get_source.return_value.get_schemas.return_value = [+ @patch.object(StripeSource, "get_schemas")+ def test_refresh_schemas_adds_only_new_schemas(self, mock_get_schemas):+ mock_get_schemas.return_value = [SourceSchema(name="existing", supports_incremental=False, supports_append=False),SourceSchema(name="new_table", supports_incremental=False, supports_append=False),]@@ -4092,10 +4079,9 @@ class TestExternalDataSource(APIBaseTest):).exists())- @patch("products.warehouse_sources.backend.presentation.views.external_data_source.base.SourceRegistry.get_source")- def test_refresh_schemas_idempotent_no_duplicates(self, mock_get_source):- mock_get_source.return_value.parse_config.return_value = None- mock_get_source.return_value.get_schemas.return_value = [+ @patch.object(StripeSource, "get_schemas")+ def test_refresh_schemas_idempotent_no_duplicates(self, mock_get_schemas):+ mock_get_schemas.return_value = [SourceSchema(name="only_one", supports_incremental=False, supports_append=False),]source = self._create_external_data_source()@@ -4114,10 +4100,9 @@ class TestExternalDataSource(APIBaseTest):1,)- @patch("products.warehouse_sources.backend.presentation.views.external_data_source.base.SourceRegistry.get_source")- def test_refresh_schemas_restores_deleted_schema_instead_of_creating_duplicate(self, mock_get_source):- mock_get_source.return_value.parse_config.return_value = None- mock_get_source.return_value.get_schemas.return_value = [+ @patch.object(StripeSource, "get_schemas")+ def test_refresh_schemas_restores_deleted_schema_instead_of_creating_duplicate(self, mock_get_schemas):+ mock_get_schemas.return_value = [SourceSchema(name="restored_table",supports_incremental=False,@@ -4161,10 +4146,9 @@ class TestExternalDataSource(APIBaseTest):self.assertFalse(restored_schema.should_sync)self.assertEqual(restored_schema.sync_type_config.get("legacy_key"), "keep")- @patch("products.warehouse_sources.backend.presentation.views.external_data_source.base.SourceRegistry.get_source")- def test_refresh_schemas_updates_labels_on_existing_schemas(self, mock_get_source):- mock_get_source.return_value.parse_config.return_value = None- mock_get_source.return_value.get_schemas.return_value = [+ @patch.object(StripeSource, "get_schemas")+ def test_refresh_schemas_updates_labels_on_existing_schemas(self, mock_get_schemas):+ mock_get_schemas.return_value = [SourceSchema(name="c123", label="general", supports_incremental=False, supports_append=False),]source = self._create_external_data_source()@@ -4180,10 +4164,9 @@ class TestExternalDataSource(APIBaseTest):schema.refresh_from_db()self.assertEqual(schema.label, "general")- @patch("products.warehouse_sources.backend.presentation.views.external_data_source.base.SourceRegistry.get_source")- def test_refresh_schemas_updates_changed_label(self, mock_get_source):- mock_get_source.return_value.parse_config.return_value = None- mock_get_source.return_value.get_schemas.return_value = [+ @patch.object(StripeSource, "get_schemas")+ def test_refresh_schemas_updates_changed_label(self, mock_get_schemas):+ mock_get_schemas.return_value = [SourceSchema(name="c123", label="renamed-channel", supports_incremental=False, supports_append=False),]source = self._create_external_data_source()@@ -4199,10 +4182,9 @@ class TestExternalDataSource(APIBaseTest):schema.refresh_from_db()self.assertEqual(schema.label, "renamed-channel")- @patch("products.warehouse_sources.backend.presentation.views.external_data_source.base.SourceRegistry.get_source")- def test_refresh_schemas_sets_label_on_new_schema(self, mock_get_source):- mock_get_source.return_value.parse_config.return_value = None- mock_get_source.return_value.get_schemas.return_value = [+ @patch.object(StripeSource, "get_schemas")+ def test_refresh_schemas_sets_label_on_new_schema(self, mock_get_schemas):+ mock_get_schemas.return_value = [SourceSchema(name="c456", label="random", supports_incremental=False, supports_append=False),]source = self._create_external_data_source()@@ -4215,10 +4197,9 @@ class TestExternalDataSource(APIBaseTest):schema = ExternalDataSchema.objects.get(team_id=self.team.pk, source_id=source.pk, name="c456")self.assertEqual(schema.label, "random")- @patch("products.warehouse_sources.backend.presentation.views.external_data_source.base.SourceRegistry.get_source")- def test_refresh_schemas_sets_label_on_restored_deleted_schema(self, mock_get_source):- mock_get_source.return_value.parse_config.return_value = None- mock_get_source.return_value.get_schemas.return_value = [+ @patch.object(StripeSource, "get_schemas")+ def test_refresh_schemas_sets_label_on_restored_deleted_schema(self, mock_get_schemas):+ mock_get_schemas.return_value = [SourceSchema(name="c789", label="announcements", supports_incremental=False, supports_append=False),]source = self._create_external_data_source()@@ -4261,10 +4242,9 @@ class TestExternalDataSource(APIBaseTest):self.assertEqual(response.status_code, 400)self.assertIn("Could not fetch schemas from source", response.json().get("message", ""))- @patch("products.warehouse_sources.backend.presentation.views.external_data_source.base.SourceRegistry.get_source")- def test_refresh_schemas_returns_zero_total_tables_seen_when_source_returns_nothing(self, mock_get_source):- mock_get_source.return_value.parse_config.return_value = None- mock_get_source.return_value.get_schemas.return_value = []+ @patch.object(StripeSource, "get_schemas")+ def test_refresh_schemas_returns_zero_total_tables_seen_when_source_returns_nothing(self, mock_get_schemas):+ mock_get_schemas.return_value = []source = self._create_external_data_source()response = self.client.post(