: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(data-warehouse): remove redundant and out-of-date code comments (#85235)
Tom Owerscff5609f0252
diff --git a/products/warehouse_sources/backend/apps.py b/products/warehouse_sources/backend/apps.pyindex cf27afe50872..97cdb48bc460 100644--- a/products/warehouse_sources/backend/apps.py+++ b/products/warehouse_sources/backend/apps.py@@ -8,9 +8,9 @@ class WarehouseSourcesConfig(AppConfig):label = "warehouse_sources"def ready(self) -> None:- # Connect the external-data-source / -schema activity-log receivers at app-population. They- # used to wire in as an import side effect of the viewset modules; the lazy API router no- # longer pulls that, so a process that never builds the router (notably the Temporal data- # import workflows, which mutate these models heavily) would drop audit logs. They live in a- # light activity_logging module because both viewsets pull in dlt via the data-import chain.+ # Connect the external-data-source / -schema activity-log receivers at app-population. The+ # lazy API router does not import the viewset modules, so a process that never builds the+ # router (notably the Temporal data import workflows, which mutate these models heavily)+ # would otherwise drop audit logs. They live in a light activity_logging module because both+ # viewsets pull in dlt via the data-import chain.from products.warehouse_sources.backend import activity_logging # noqa: F401, PLC0415diff --git a/products/warehouse_sources/backend/models/table.py b/products/warehouse_sources/backend/models/table.pyindex 77e82af6a838..4b088e71c8a8 100644--- a/products/warehouse_sources/backend/models/table.py+++ b/products/warehouse_sources/backend/models/table.py@@ -502,8 +502,9 @@ class DataWarehouseTable(CreatedMetaFields, UpdatedMetaFields, UUIDTModel, Delet# chdb doesn't support parameterized querieschdb_query = f"SET use_hive_partitioning = 0; DESCRIBE TABLE {s3_table_func}" % quoted_placeholders- # TODO: upgrade chdb once https://github.com/chdb-io/chdb/issues/342 is actually resolved- # See https://github.com/chdb-io/chdb/pull/374 for the fix+ # Workaround for chdb not honouring the CSV double-quote setting. The upstream fix+ # (https://github.com/chdb-io/chdb/pull/374) is merged but is not in the pinned 3.3.0,+ # so this SET stays until chdb is upgraded past that release.if self._is_csv_format() and self.csv_allow_double_quotes is not None:chdb_query = (f"SET format_csv_allow_double_quotes = {1 if self.csv_allow_double_quotes else 0}; {chdb_query}"diff --git a/products/warehouse_sources/backend/presentation/views/external_data_schema.py b/products/warehouse_sources/backend/presentation/views/external_data_schema.pyindex acc26417b85e..a4d68b7ef2b8 100644--- a/products/warehouse_sources/backend/presentation/views/external_data_schema.py+++ b/products/warehouse_sources/backend/presentation/views/external_data_schema.py@@ -844,7 +844,6 @@ class ExternalDataSchemaSerializer(UserAccessControlSerializerMixin, serializersif incremental_field_changed:if instance.table is not None and isinstance(incremental_field, str):- # Get the max_value and set it on incremental_field_last_valuemax_value = instance.table.get_max_value_for_column(incremental_field)if max_value:instance.update_incremental_field_value(max_value, save=False)diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/extract.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/extract.pyindex 41aa93599c6f..3ceb849841f3 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/extract.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/extract.py@@ -353,7 +353,6 @@ def validate_incremental_sync(*,is_first_sync: bool = True,) -> None:- # Check for duplicate primary keysif is_incremental and resource.has_duplicate_primary_keys:raise DuplicatePrimaryKeysException(f"The primary keys for this table are not unique. We can't sync incrementally until the table "diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/memory_governor.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/memory_governor.pyindex 7f81166ad5ae..6c384fa919c9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/memory_governor.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/memory_governor.py@@ -81,7 +81,7 @@ _MARGINAL_PER_WORKER_MB = 133.0_MARGINAL_PER_SOURCE_MB = 0.73#: Beyond 4 partition workers the measured wall-clock gains vanish while memory keeps climbing._MAX_PARALLEL_PARTITIONS = 4-#: Per-call knobs the governor no longer tunes (mpp is the memory dial): deltalite's defaults, kept+#: Per-call knobs the governor does not tune (mpp is the memory dial): deltalite's defaults, kept#: explicit so the write is deterministic._MAX_PARALLEL_FILES = 4_DEFAULT_BUFFERED_BYTES = 64 * MBdiff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test/test_utils.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test/test_utils.pyindex 3a96c1a45e4d..76918c1c62f8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test/test_utils.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test/test_utils.py@@ -485,7 +485,6 @@ def test_get_max_decimal_type_returns_correct_decimal_type(decimals: list[decimal.Decimal],expected: pa.Decimal128Type | pa.Decimal256Type,):- """Test whether expected PyArrow decimal type variant is returned."""result = _get_max_decimal_type(decimals)assert result == expected@@ -1002,7 +1001,6 @@ def test_raise_on_nullability_drift_permits_valid_batches(def test_evolve_pyarrow_schema_with_struct_containing_datetime_and_decimal():- """Test that evolve_pyarrow_schema can handle struct columns with non-JSON-serializable types."""metadata_struct_type = pa.struct([("role", pa.string()),@@ -1041,7 +1039,6 @@ def test_evolve_pyarrow_schema_with_struct_containing_datetime_and_decimal():def test_evolve_pyarrow_schema_with_list_containing_datetime():- """Test that evolve_pyarrow_schema can handle list columns with non-JSON-serializable types."""arrow_table = pa.table({"id": pa.array([1, 2], type=pa.int64()),diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/load/processor.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/load/processor.pyindex d84b29d5b9d0..9db501544429 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/load/processor.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/load/processor.py@@ -982,7 +982,6 @@ def _process_message_reported(file_count=len(delta_table.file_uris()),)- # Handle partial data loading for first-ever syncasync_to_sync(_handle_partial_data_loading)(export_signal=export_signal,job=job,diff --git a/products/warehouse_sources/backend/temporal/data_imports/row_tracking.py b/products/warehouse_sources/backend/temporal/data_imports/row_tracking.pyindex d594998bd802..c77e9811f6dd 100644--- a/products/warehouse_sources/backend/temporal/data_imports/row_tracking.py+++ b/products/warehouse_sources/backend/temporal/data_imports/row_tracking.py@@ -227,7 +227,6 @@ async def will_hit_billing_limit(team_id: int, source: "ExternalDataSource", logawait logger.adebug(f"BillingLimits: rows_synced_in_billing_period = {rows_synced_in_billing_period}")- # Get all in-progress rows for all teams in orgrows_per_team = await asyncio.gather(*[get_all_rows_for_team(t_id) for t_id in all_teams_in_org])existing_rows_in_progress = sum(rows_per_team)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/client.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/client.pyindex dc91f914f447..d1af5c1889a2 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/client.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/client.py@@ -256,7 +256,6 @@ class BingAdsClient:end_date=end_date,)- # Download and extract CSV from ZIPcsv_data = download_and_extract_report_csv(reporting_service_manager=reporting_service_manager,report_request=report_request,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/tests/test_bing_ads.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/tests/test_bing_ads.pyindex f4879dd7cab0..32ee84b78758 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/tests/test_bing_ads.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/tests/test_bing_ads.py@@ -38,7 +38,6 @@ class TestBingAdsHelperFunctions:"""Test helper functions in bing_ads.py and utils.py."""def test_parse_csv_to_dicts_valid_data(self):- """Test parsing valid CSV report data."""csv_data = """TimePeriod,CampaignId,CampaignName,Impressions,Clicks2024-01-01,123,Test Campaign,1000,502024-01-02,123,Test Campaign,1200,60"""@@ -52,7 +51,6 @@ class TestBingAdsHelperFunctions:assert result[1]["TimePeriod"] == "2024-01-02"def test_parse_csv_to_dicts_with_null_values(self):- """Test parsing CSV with null values (--) and empty strings."""csv_data = """TimePeriod,CampaignId,CampaignName,Impressions,Clicks2024-01-01,123,Test Campaign,--,2024-01-02,456,--,1000,50"""@@ -65,7 +63,6 @@ class TestBingAdsHelperFunctions:assert result[1]["CampaignName"] is Nonedef test_fetch_data_in_yearly_chunks_single_chunk(self):- """Test fetching data within a single year."""mock_client = Mock()mock_client.get_data_by_resource.return_value = iter([[{"CampaignId": "123", "Clicks": "100"}]])@@ -92,7 +89,6 @@ class TestBingAdsHelperFunctions:)def test_fetch_data_in_yearly_chunks_multiple_chunks(self):- """Test fetching data across multiple years."""mock_client = Mock()mock_client.get_data_by_resource.side_effect = [iter([[{"year": "2023"}]]),@@ -330,7 +326,6 @@ class TestBingAdsSource:@patch("products.warehouse_sources.backend.temporal.data_imports.sources.bing_ads.bing_ads.BingAdsClient")@patch("products.warehouse_sources.backend.temporal.data_imports.sources.bing_ads.bing_ads.integrations")def test_bing_ads_source_campaigns(self, mock_integrations, mock_client_class):- """Test source function for campaigns (non-report endpoint)."""mock_integrations.BING_ADS_DEVELOPER_TOKEN = "test_dev_token"mock_client = Mock()@@ -362,7 +357,6 @@ class TestBingAdsSource:@patch("products.warehouse_sources.backend.temporal.data_imports.sources.bing_ads.bing_ads.BingAdsClient")@patch("products.warehouse_sources.backend.temporal.data_imports.sources.bing_ads.bing_ads.integrations")def test_bing_ads_source_report_full_refresh(self, mock_integrations, mock_client_class, mock_fetch_chunks):- """Test source function for report endpoint with full refresh."""mock_integrations.BING_ADS_DEVELOPER_TOKEN = "test_dev_token"mock_client = Mock()@@ -407,7 +401,6 @@ class TestBingAdsSource:def test_bing_ads_source_report_incremental(self, _name, last_value, mock_integrations, mock_client_class, mock_fetch_chunks):- """Test source function for report endpoint with incremental sync."""mock_integrations.BING_ADS_DEVELOPER_TOKEN = "test_dev_token"mock_client = Mock()@@ -472,7 +465,6 @@ class TestBingAdsSource:@patch("products.warehouse_sources.backend.temporal.data_imports.sources.bing_ads.bing_ads.integrations")def test_bing_ads_source_missing_developer_token(self, mock_integrations):- """Test source function raises error when developer token is missing."""mock_integrations.BING_ADS_DEVELOPER_TOKEN = Noneresult = bing_ads_source(@@ -548,7 +540,6 @@ class TestBingAdsSource:@patch("products.warehouse_sources.backend.temporal.data_imports.sources.bing_ads.bing_ads.BingAdsClient")@patch("products.warehouse_sources.backend.temporal.data_imports.sources.bing_ads.bing_ads.integrations")def test_bing_ads_source_incremental_missing_field(self, mock_integrations, mock_client_class):- """Test source function raises error when incremental field is missing."""mock_integrations.BING_ADS_DEVELOPER_TOKEN = "test_dev_token"result = bing_ads_source(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/tests/test_bing_ads_client.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/tests/test_bing_ads_client.pyindex 1dd1cfdda510..0fe5980e6fe6 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/tests/test_bing_ads_client.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/tests/test_bing_ads_client.py@@ -86,7 +86,6 @@ class TestBingAdsClient:@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.bing_ads.client.ServiceClient")def test_get_customer_id_success(self, mock_service_client):- """Test successful customer ID retrieval."""mock_user = mock.MagicMock()mock_user.CustomerId = self.customer_id@@ -290,7 +289,6 @@ class TestBingAdsClient:@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.bing_ads.client.ServiceClient")def test_get_campaigns_success(self, mock_service_client):- """Test successful campaigns retrieval."""mock_campaign = mock.MagicMock()mock_campaign.Id = 123mock_campaign.Name = "Test Campaign"diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/tests/test_bing_ads_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/tests/test_bing_ads_source.pyindex f8580a8c25d6..49ecc8a56a26 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/tests/test_bing_ads_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/tests/test_bing_ads_source.py@@ -26,11 +26,9 @@ class TestBingAdsSource:)def test_source_type(self):- """Test source type is correctly set."""assert self.source.source_type == ExternalDataSourceType.BINGADSdef test_get_source_config(self):- """Test source configuration is properly structured."""config = self.source.get_source_configassert config.name.value == "BingAds"@@ -72,7 +70,6 @@ class TestBingAdsSource:@mock.patch.object(BingAdsSource, "get_oauth_integration")def test_validate_credentials_success(self, mock_get_oauth):- """Test successful credential validation."""mock_integration = mock.MagicMock()mock_get_oauth.return_value = mock_integration@@ -108,7 +105,6 @@ class TestBingAdsSource:assert mock_capture.called is expect_capture_calleddef test_get_schemas(self):- """Test getting available schemas."""schemas = self.source.get_schemas(self.valid_config, self.team_id)assert len(schemas) > 0@@ -134,7 +130,6 @@ class TestBingAdsSource:@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.bing_ads.source.bing_ads_source")@mock.patch.object(BingAdsSource, "get_oauth_integration")def test_source_for_pipeline_campaigns(self, mock_get_oauth, mock_bing_ads_source):- """Test creating source for pipeline with campaigns."""mock_integration = mock.MagicMock()mock_integration.access_token = "test_access_token"mock_integration.refresh_token = "test_refresh_token"@@ -171,7 +166,6 @@ class TestBingAdsSource:@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.bing_ads.source.bing_ads_source")@mock.patch.object(BingAdsSource, "get_oauth_integration")def test_source_for_pipeline_report_incremental(self, mock_get_oauth, mock_bing_ads_source):- """Test creating source for pipeline with incremental report."""mock_integration = mock.MagicMock()mock_integration.access_token = "test_access_token"mock_integration.refresh_token = "test_refresh_token"@@ -207,7 +201,6 @@ class TestBingAdsSource:@mock.patch.object(BingAdsSource, "get_oauth_integration")def test_source_for_pipeline_missing_access_token(self, mock_get_oauth):- """Test source_for_pipeline raises error when access token is missing."""mock_integration = mock.MagicMock()mock_integration.access_token = Nonemock_integration.refresh_token = "test_refresh_token"@@ -224,7 +217,6 @@ class TestBingAdsSource:@mock.patch.object(BingAdsSource, "get_oauth_integration")def test_source_for_pipeline_missing_refresh_token(self, mock_get_oauth):- """Test source_for_pipeline raises error when refresh token is missing."""mock_integration = mock.MagicMock()mock_integration.access_token = "test_access_token"mock_integration.refresh_token = Nonediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/test/test_config.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/test/test_config.pyindex eb28a37b0ff3..c764059b80ca 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/test/test_config.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/test/test_config.py@@ -7,8 +7,6 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common impdef test_empty_config():- """Test `config.to_config` with an empty class."""-@config.configclass TestConfig(config.Config):pass@@ -18,8 +16,6 @@ def test_empty_config():def test_basic_to_config():- """Test `config.to_config` with a basic class."""-@config.configclass TestConfig(config.Config):a: str@@ -39,8 +35,6 @@ def test_basic_to_config():def test_basic_to_config_converters():- """Test `config.to_config` can convert using converters."""-@config.configclass TestConfig(config.Config):a: int = config.value(converter=int)@@ -427,8 +421,6 @@ def test_to_config_override_alias_fallback():def test_to_config_union_nested_configs():- """Test `config.to_config` with a union of nested configs."""-@config.configclass A:a: str@@ -464,8 +456,6 @@ def test_to_config_union_nested_configs():def test_to_config_union_nested_configs_with_alias():- """Test `config.to_config` with a union of nested configs using alias."""-@config.configclass A:a: strdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/test/test_sql.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/test/test_sql.pyindex bd979963c761..fa37bea0551d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/test/test_sql.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/test/test_sql.py@@ -18,7 +18,6 @@ class SimpleColumn(Column):def test_table_get_item():- """Test `Table.__getitem__` with `int` and `str` keys."""column_name = "some_column"column = SimpleColumn(column_name)table = Table(name="test", columns=[column])@@ -37,7 +36,6 @@ def test_table_get_item():def test_table_contains():- """Test `Table.__contains__` returns `True` with existing column."""column_name = "some_column"column = SimpleColumn(column_name)table = Table(name="test", columns=[column])@@ -47,7 +45,6 @@ def test_table_contains():def test_table_len():- """Test `Table.__len__` returns number of columns."""column_name = "some_column"column = SimpleColumn(column_name)table = Table(name="test", columns=[column])@@ -60,7 +57,6 @@ def test_table_len():def test_table_to_arrow_schema():- """Test `to_arrow_schema` method returns fields based on columns."""column_name = "some_column"column_0 = SimpleColumn(column_name)column_1 = SimpleColumn(column_name)@@ -81,7 +77,6 @@ def test_table_to_arrow_schema():def test_table_fully_qualified_name():- """Test `Table` generates correct fully qualified names."""column_name = "some_column"column = SimpleColumn(column_name)table = Table(name="test", columns=[column])@@ -94,8 +89,6 @@ def test_table_fully_qualified_name():def test_table_reference_from_fully_qualified_name():- """Test initializing a `TableReference` from a fully qualified name."""-table_ref = TableReference.from_fully_qualified_name("database.schema.test")assert table_ref.fully_qualified_name == "database.schema.test"assert table_ref.name == "test"diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_ads.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_ads.pyindex 0d05e61e6059..7511938ebb0d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_ads.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_ads.py@@ -77,7 +77,6 @@ class TestLinkedinAdsHelperFunctions:"""Test helper functions in linkedin_ads.py."""def test_extract_type_and_id_from_urn_valid(self):- """Test extracting ID and type from valid LinkedIn URN."""urn = "urn:li:sponsoredCampaign:12345678"result = _extract_type_and_id_from_urn(urn)@@ -98,14 +97,12 @@ class TestLinkedinAdsHelperFunctions:assert _extract_type_and_id_from_urn(malformed) is Nonedef test_convert_date_object_to_date_valid(self):- """Test converting LinkedIn date object to Python date."""date_obj = {"year": 2024, "month": 3, "day": 15}result = _convert_date_object_to_date(date_obj)assert result == dt.date(2024, 3, 15)def test_convert_date_object_to_date_invalid(self):- """Test converting invalid date object returns None."""invalid_cases = [{"year": 2024, "month": 3}, # Missing day{}, # Empty dict@@ -117,7 +114,6 @@ class TestLinkedinAdsHelperFunctions:assert result is Nonedef test_convert_timestamp_to_date_valid(self):- """Test converting LinkedIn timestamp to date."""timestamp_ms = 1709654400000last_modified = {"time": timestamp_ms}result = _convert_timestamp_to_date(last_modified)@@ -129,7 +125,6 @@ class TestFlattenLinkedinRecord:"""Test _flatten_linkedin_record function."""def test_flatten_date_range(self):- """Test flattening dateRange field."""record = {"dateRange": {"start": {"year": 2024, "month": 1, "day": 1}, "end": {"year": 2024, "month": 1, "day": 31}}}@@ -151,7 +146,6 @@ class TestFlattenLinkedinRecord:assert result["date_end"] == dt.date(2024, 1, 31)def test_flatten_urn_columns(self):- """Test flattening URN columns."""record = {"campaignGroup": "urn:li:sponsoredCampaignGroup:123456789","campaign": "urn:li:sponsoredCampaign:987654321",@@ -174,7 +168,6 @@ class TestFlattenLinkedinRecord:assert result["campaign_id"] == 987654321def test_flatten_integer_fields(self):- """Test conversion of integer fields."""schema = _stats_schema(["impressions", "clicks"])result = _flatten_linkedin_record({"impressions": 1000, "clicks": 50}, schema)@@ -315,7 +308,6 @@ class TestFlattenLinkedinRecord:pa.unify_schemas([null_schema, value_schema])def test_flatten_change_audit_stamps(self):- """Test flattening changeAuditStamps field."""record = {"changeAuditStamps": {"created": {"time": 1709654400000}, "lastModified": {"time": 1709740800000}}}schema = LinkedinAdsSchema(name="test",@@ -335,7 +327,6 @@ class TestFlattenLinkedinRecord:assert str(result["last_modified_time"]) == "2024-03-06"def test_flatten_pivot_values(self):- """Test flattening pivotValues field."""record = {"pivotValues": ["urn:li:sponsoredCampaign:555666777", "urn:li:sponsoredAccount:888999000"]}schema = LinkedinAdsSchema(name="test",@@ -376,7 +367,6 @@ class TestFlattenLinkedinRecord:assert result["targetingCriteria"]["ages"]["min"] == 25def test_flatten_missing_field_returns_none(self):- """Test missing fields return None."""record: dict[str, typing.Any] = {} # Empty recordschema = LinkedinAdsSchema(name="test",@@ -508,7 +498,6 @@ class TestLinkedinAdsClientFunction:"""Test linkedin_ads_client function."""def test_linkedin_ads_client_no_access_token(self, mock_integration_model):- """Test client creation with no access token raises error."""mock_integration = mock.MagicMock()mock_integration.access_token = Nonemock_integration.sensitive_config = {} # no refresh token → not expired, skips refresh@@ -680,7 +669,6 @@ class TestLinkedinAdsSource:"""Test linkedin_ads_source function."""def test_linkedin_ads_source_with_incremental(self, mock_client_func):- """Test linkedin_ads_source with incremental field."""mock_client = mock.MagicMock()# Analytics endpoints are single-shot: one page, no next_page_token.mock_client.get_data_by_resource.return_value = [diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_client.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_client.pyindex e2c13ab82080..02ed0ca0cd45 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_client.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_client.py@@ -28,13 +28,11 @@ class TestLinkedinAdsClient:self.account_id = "12345"def test_init_with_empty_token_raises_error(self):- """Test client initialization with empty token raises ValueError."""with pytest.raises(ValueError, match="Access token required"):LinkedinAdsClient("")@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.linkedin_ads.client.RestliClient")def test_get_accounts_success(self, mock_restli_client):- """Test successful accounts retrieval."""mock_response = mock.MagicMock()mock_response.status_code = 200mock_response.elements = [{"id": "123", "name": "Test Account"}]@@ -87,7 +85,6 @@ class TestLinkedinAdsClient:@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.linkedin_ads.client.RestliClient")def test_get_accounts_api_error(self, mock_restli_client):- """Test accounts retrieval with API error."""mock_response = mock.MagicMock()mock_response.status_code = 401mock_response.response.text = "Unauthorized"@@ -102,7 +99,6 @@ class TestLinkedinAdsClient:@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.linkedin_ads.client.RestliClient")def test_get_campaigns_pagination(self, mock_restli_client):- """Test successful campaigns retrieval with pagination."""# First page responsemock_response1 = mock.MagicMock()mock_response1.status_code = 200@@ -349,7 +345,6 @@ class TestLinkedinAdsClient:}def test_format_date_range(self):- """Test date range formatting for LinkedIn API."""client = LinkedinAdsClient(self.access_token)result = client._format_date_range("2024-01-15", "2024-02-20")diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_source.pyindex 2f6582ae987d..acfa73253d7b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_source.py@@ -151,7 +151,6 @@ class TestLinkedInAdsSource:assert schemas[name].should_sync_defaultdef test_validate_credentials_missing_account_id(self):- """Test credential validation with missing account ID."""invalid_config = LinkedinAdsSourceConfig(linkedin_ads_integration_id=456, account_id="")is_valid, error_message = self.source.validate_credentials(invalid_config, self.team_id)@@ -181,8 +180,6 @@ class TestLinkedInAdsSource:@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.linkedin_ads.source.Integration")def test_validate_credentials_integration_not_found(self, mock_integration_model):- """Test credential validation when integration doesn't exist."""-# Mock DoesNotExist exceptionclass MockDoesNotExist(Exception):pass@@ -201,8 +198,6 @@ class TestLinkedInAdsSource:"products.warehouse_sources.backend.temporal.data_imports.sources.linkedin_ads.source.capture_exception")def test_validate_credentials_unexpected_error(self, mock_capture_exception, mock_integration_model):- """Test credential validation with unexpected error."""-# Mock DoesNotExist exceptionclass MockDoesNotExist(Exception):passdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/mongo.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/mongo.pyindex 6fa585ec6be9..f3b6758b2b23 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/mongo.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/mongo.py@@ -427,8 +427,9 @@ def _get_schema_from_query(collection: Collection) -> list[tuple[str, str]]:def _determine_field_type_from_bson_types(bson_types: list[str]) -> str:- """Determine field type from BSON types."""- # If multiple types exist, prioritize based on hierarchy+ # A field sampled across documents can hold several BSON types. This returns one type by walking+ # the fixed precedence list below and taking the first present, not a type that fits every+ # observed value: a field mixing int and string resolves to integer, because int outranks string.type_priority = {"objectId": "string","string": "string",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_ads.py b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_ads.pyindex 468361053d2c..88be4cef22eb 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_ads.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_ads.py@@ -27,7 +27,6 @@ class TestRedditAdsHelperFunctions:"""Test helper functions in reddit_ads.py."""def test_get_incremental_date_range_with_datetime(self):- """Test getting date range with datetime incremental value."""last_value = dt.datetime(2024, 3, 15, 14, 30, 0)starts_at, ends_at = _get_incremental_date_range(True, last_value)@@ -35,7 +34,6 @@ class TestRedditAdsHelperFunctions:assert ends_at.endswith(":00:00Z") # Should be next hour (rounded to hour)def test_get_incremental_date_range_with_date(self):- """Test getting date range with date incremental value."""last_value = dt.date(2024, 3, 15)starts_at, ends_at = _get_incremental_date_range(True, last_value)@@ -43,7 +41,6 @@ class TestRedditAdsHelperFunctions:assert ends_at.endswith(":00:00Z") # Should be next hour (rounded to hour)def test_get_incremental_date_range_with_string(self):- """Test getting date range with string incremental value."""last_value = "2024-03-15T14:30:00Z"starts_at, ends_at = _get_incremental_date_range(True, last_value)@@ -51,7 +48,6 @@ class TestRedditAdsHelperFunctions:assert ends_at.endswith(":00:00Z") # Should be next hour (rounded to hour)def test_get_incremental_date_range_with_invalid_string(self):- """Test getting date range with invalid string falls back to initial datetime."""last_value = "invalid-date"starts_at, ends_at = _get_incremental_date_range(True, last_value)@@ -60,7 +56,6 @@ class TestRedditAdsHelperFunctions:assert ends_at.endswith(":00:00Z") # Should be next hour (rounded to hour)def test_get_incremental_date_range_no_incremental(self):- """Test getting date range without incremental field."""starts_at, ends_at = _get_incremental_date_range(False)# Should use initial_datetime@@ -68,7 +63,6 @@ class TestRedditAdsHelperFunctions:assert ends_at.endswith(":00:00Z") # Should be next hour (rounded to hour)def test_get_incremental_date_range_none_value(self):- """Test getting date range with None incremental value."""starts_at, ends_at = _get_incremental_date_range(True, None)# Should use initial_datetime@@ -80,7 +74,6 @@ class TestGetResource:"""Test get_resource function."""def test_get_resource_campaigns(self):- """Test getting campaigns resource configuration."""resource = get_resource("campaigns", "test_account", False)assert resource["name"] == "campaigns"@@ -92,7 +85,6 @@ class TestGetResource:assert resource["write_disposition"] == "replace"def test_get_resource_campaigns_incremental(self):- """Test getting campaigns resource with incremental configuration."""resource = get_resource("campaigns", "test_account", True, dt.datetime(2024, 3, 15, 14, 30))assert isinstance(resource["write_disposition"], dict)@@ -105,7 +97,6 @@ class TestGetResource:assert "modified_at[after]" in endpoint_paramsdef test_get_resource_campaign_report_incremental(self):- """Test getting campaign report resource with incremental configuration."""resource = get_resource("campaign_report", "test_account", True, dt.datetime(2024, 3, 15, 14, 30))assert isinstance(resource["write_disposition"], dict)@@ -120,12 +111,10 @@ class TestGetResource:assert endpoint_json["data"]["ends_at"].endswith(":00:00Z") # Should be next hour (rounded to hour)def test_get_resource_unknown_endpoint(self):- """Test getting unknown endpoint raises ValueError."""with pytest.raises(ValueError, match="Unknown endpoint: unknown_endpoint"):get_resource("unknown_endpoint", "test_account", False)def test_get_resource_invalid_endpoint_type(self):- """Test getting resource with invalid endpoint type raises ValueError."""# This would require mocking REDDIT_ADS_CONFIG to have invalid endpoint# For now, we'll test the happy path since the config is properly structuredresource = get_resource("campaigns", "test_account", False)@@ -211,13 +200,11 @@ class TestRedditAdsPaginator:"""Test RedditAdsPaginator class."""def test_paginator_init(self):- """Test paginator initialization."""paginator = RedditAdsPaginator()assert paginator._next_url is Noneassert paginator._has_next_page is Falsedef test_update_state_with_pagination(self):- """Test updating state with pagination data."""paginator = RedditAdsPaginator()mock_response = mock.MagicMock()@@ -229,7 +216,6 @@ class TestRedditAdsPaginator:assert paginator._has_next_page is Truedef test_update_state_without_pagination(self):- """Test updating state without pagination data."""paginator = RedditAdsPaginator()mock_response = mock.MagicMock()@@ -241,7 +227,6 @@ class TestRedditAdsPaginator:assert paginator._has_next_page is Falsedef test_update_state_invalid_json(self):- """Test updating state with invalid JSON."""paginator = RedditAdsPaginator()mock_response = mock.MagicMock()@@ -253,7 +238,6 @@ class TestRedditAdsPaginator:assert paginator._has_next_page is Falsedef test_update_request_with_next_url(self):- """Test updating request with next URL."""paginator = RedditAdsPaginator()paginator._next_url = "https://api.reddit.com/next-page"@@ -263,7 +247,6 @@ class TestRedditAdsPaginator:assert mock_request.url == "https://api.reddit.com/next-page"def test_update_request_without_next_url(self):- """Test updating request without next URL."""paginator = RedditAdsPaginator()mock_request = mock.MagicMock()diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_source.pyindex c7f70565de9f..d707169ed02b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_source.py@@ -44,11 +44,9 @@ class TestRedditAdsSource:self.config = RedditAdsSourceConfig(reddit_integration_id=456, account_id="789")def test_source_type(self):- """Test source type property."""assert self.source.source_type == ExternalDataSourceType.REDDITADSdef test_get_source_config(self):- """Test get_source_config returns proper configuration."""config = self.source.get_source_configassert config.name.value == "RedditAds"@@ -72,7 +70,6 @@ class TestRedditAdsSource:assert account_field.integrationKind == "reddit-ads"def test_validate_credentials_missing_account_id(self):- """Test credential validation with missing account ID."""invalid_config = RedditAdsSourceConfig(reddit_integration_id=456, account_id="")is_valid, error_message = self.source.validate_credentials(invalid_config, self.team_id)@@ -82,7 +79,6 @@ class TestRedditAdsSource:assert "Account ID and Reddit Ads integration are required" in error_messagedef test_validate_credentials_missing_integration_id(self):- """Test credential validation with missing integration ID."""invalid_config = RedditAdsSourceConfig(reddit_integration_id=0, account_id="789")is_valid, error_message = self.source.validate_credentials(invalid_config, self.team_id)@@ -95,7 +91,6 @@ class TestRedditAdsSource:"products.warehouse_sources.backend.temporal.data_imports.sources.reddit_ads.source.RedditAdsSource.get_oauth_integration")def test_validate_credentials_success(self, mock_get_oauth_integration):- """Test successful credential validation."""mock_integration = mock.MagicMock()mock_integration.access_token = "test_token"mock_get_oauth_integration.return_value = mock_integration@@ -231,7 +226,6 @@ class TestRedditAdsSource:assert expected_fragment in str(excinfo.value).lower()def test_get_schemas(self):- """Test get_schemas returns all endpoint schemas."""schemas = self.source.get_schemas(self.config, self.team_id)expected_endpoints = set(REDDIT_ADS_CONFIG)@@ -296,7 +290,6 @@ class TestRedditAdsSource:"products.warehouse_sources.backend.temporal.data_imports.sources.reddit_ads.source.RedditAdsSource.get_oauth_integration")def test_source_for_pipeline_success(self, mock_get_oauth_integration):- """Test source_for_pipeline with valid integration."""mock_integration = mock.MagicMock()mock_integration.access_token = "test_token"mock_get_oauth_integration.return_value = mock_integration@@ -335,7 +328,6 @@ class TestRedditAdsSource:"products.warehouse_sources.backend.temporal.data_imports.sources.reddit_ads.source.RedditAdsSource.get_oauth_integration")def test_source_for_pipeline_no_access_token(self, mock_get_oauth_integration):- """Test source_for_pipeline with no access token raises error."""mock_integration = mock.MagicMock()mock_integration.access_token = Nonemock_get_oauth_integration.return_value = mock_integration@@ -354,7 +346,6 @@ class TestRedditAdsSource:"products.warehouse_sources.backend.temporal.data_imports.sources.reddit_ads.source.RedditAdsSource.get_oauth_integration")def test_source_for_pipeline_with_incremental(self, mock_get_oauth_integration):- """Test source_for_pipeline with incremental field."""mock_integration = mock.MagicMock()mock_integration.access_token = "test_token"mock_get_oauth_integration.return_value = mock_integrationdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/test/test_auth.py b/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/test/test_auth.pyindex 2a139df0c7be..7d25b9c01b81 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/test/test_auth.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/test/test_auth.py@@ -9,7 +9,6 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.salesforcedef test_salesforce_refresh_access_token_raises_on_client_failure():- """Test whether an exception is raised when failing with a client error."""status_code = 400error_description = "Bad client!"@@ -32,7 +31,6 @@ def test_salesforce_refresh_access_token_raises_on_client_failure():def test_salesforce_refresh_access_token_raises_on_server_failure():- """Test whether an exception is raised when failing with a server error."""status_code = 500response_body = "something went terribly wrong"@@ -55,7 +53,6 @@ def test_salesforce_refresh_access_token_raises_on_server_failure():def test_get_salesforce_access_token_from_code_raises_on_client_failure():- """Test whether an exception is raised when failing with a client error."""status_code = 400error_description = "Bad client!"@@ -78,7 +75,6 @@ def test_get_salesforce_access_token_from_code_raises_on_client_failure():def test_get_salesforce_access_token_from_code_raises_on_server_failure():- """Test whether an exception is raised when failing with a server error."""status_code = 500response_body = "something went terribly wrong"diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/stripe.py b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/stripe.pyindex de2618552913..cb389329e0bc 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/stripe.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/stripe.py@@ -688,7 +688,6 @@ def get_rows(logger.debug(f"Stripe: reading from resource {resource}")- # Get the incremental field name for this endpointincremental_field_config = APPEND_ONLY_INCREMENTAL_FIELDS.get(endpoint, [])incremental_field_name = incremental_field_config[0]["field"] if incremental_field_config else "created"diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads.py b/products/warehouse_sources/backend/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads.pyindex b303f0aec342..581216464fe4 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads.py@@ -61,7 +61,6 @@ class TestTikTokAdsHelpers:"""Test suite for TikTok Ads helper functions."""def test_flatten_tiktok_report_record_nested(self):- """Test flattening nested TikTok report structure."""nested_record = {"dimensions": {"campaign_id": "123456", "stat_time_day": "2025-09-27"},"metrics": {"clicks": "947", "impressions": "23241", "spend": "125.50"},@@ -80,7 +79,6 @@ class TestTikTokAdsHelpers:assert result == expecteddef test_flatten_tiktok_report_record_flat(self):- """Test flattening already flat record (entity endpoints)."""flat_record = {"campaign_id": "123456", "campaign_name": "Test Campaign", "status": "ENABLE"}result = TikTokReportResource.transform_entity_reports([flat_record])[0]@@ -89,7 +87,6 @@ class TestTikTokAdsHelpers:assert result == expecteddef test_flatten_tiktok_reports(self):- """Test batch flattening of TikTok reports."""reports = [{"dimensions": {"campaign_id": "123"}, "metrics": {"clicks": "100"}},{"dimensions": {"campaign_id": "456"}, "metrics": {"clicks": "200"}},@@ -111,7 +108,6 @@ class TestTikTokAdsHelpers:])def test_get_incremental_date_range(self, name, should_use_incremental, last_value, expected_days_back):- """Test incremental date range calculation."""start_date, end_date = TikTokDateRangeManager.get_incremental_range(should_use_incremental, last_value)start_dt = datetime.strptime(start_date, "%Y-%m-%d")@@ -121,7 +117,6 @@ class TestTikTokAdsHelpers:assert days_diff <= expected_days_back + 1def test_get_incremental_date_range_parse_error(self):- """Test date range calculation with invalid last value."""start_date, end_date = TikTokDateRangeManager.get_incremental_range(True, "invalid_date")start_dt = datetime.strptime(start_date, "%Y-%m-%d")@@ -163,7 +158,6 @@ class TestTikTokAdsHelpers:])def test_generate_date_chunks(self, name, start_date, end_date, chunk_days, expected_chunks):- """Test date chunk generation."""chunks = TikTokDateRangeManager.generate_chunks(start_date, end_date, chunk_days)assert len(chunks) == expected_chunksdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads_source.pyindex cc2fd9b4c9a9..0168d7410d6a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads_source.py@@ -55,7 +55,6 @@ class TestTikTokAdsSource:self.mock_integration.team_id = self.team_iddef test_source_type(self):- """Test that source type is correctly identified."""assert self.source.source_type == ExternalDataSourceType.TIKTOKADS@parameterized.expand(@@ -314,7 +313,6 @@ class TestTikTokAdsSource:self.source.get_oauth_accounts(self.integration_id, self.team_id)def test_get_source_config(self):- """Test source configuration generation."""config = self.source.get_source_configassert config.name.value == "TikTokAds"@@ -346,7 +344,6 @@ class TestTikTokAdsSource:])def test_validate_credentials(self, name, advertiser_id, integration_id, expected_valid, expected_error):- """Test credential validation scenarios."""config = TikTokAdsSourceConfig(advertiser_id=advertiser_id, tiktok_integration_id=integration_id)with patch.object(self.source, "get_oauth_integration") as mock_get_integration:@@ -362,7 +359,6 @@ class TestTikTokAdsSource:assert expected_error in str(error)def test_get_schemas(self):- """Test schema retrieval."""schemas = self.source.get_schemas(self.config, self.team_id)expected_schemas = {@@ -432,7 +428,6 @@ class TestTikTokAdsSource:@patch("products.warehouse_sources.backend.temporal.data_imports.sources.tiktok_ads.source.tiktok_ads_source")def test_source_for_pipeline_success(self, mock_tiktok_source):- """Test successful pipeline source creation."""inputs = SourceInputs(schema_name="campaigns",schema_id="campaigns_schema",@@ -470,7 +465,6 @@ class TestTikTokAdsSource:)def test_source_for_pipeline_no_access_token(self):- """Test pipeline source creation fails without access token."""inputs = SourceInputs(schema_name="campaigns",schema_id="campaigns_schema",@@ -495,7 +489,6 @@ class TestTikTokAdsSource:self.source.source_for_pipeline(self.config, MagicMock(), inputs)def test_validate_credentials_exception_handling(self):- """Test credential validation handles exceptions properly."""config = TikTokAdsSourceConfig(advertiser_id="123456789", tiktok_integration_id=123)with patch.object(self.source, "get_oauth_integration") as mock_get_integration:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads_utils.py b/products/warehouse_sources/backend/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads_utils.pyindex 2b02c3c57950..ada0b88881f7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads_utils.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads_utils.py@@ -30,7 +30,6 @@ class TestFlattenFunctions:"""Test suite for TikTok report flattening functions."""def test_flatten_tiktok_report_record_nested_structure(self):- """Test flattening nested TikTok report structure with dimensions and metrics."""nested_record = {"dimensions": {"campaign_id": "123456789", "stat_time_day": "2025-09-27", "adgroup_id": "987654321"},"metrics": {"clicks": "947", "impressions": "23241", "spend": "125.50", "cpm": "5.40", "ctr": "4.08"},@@ -68,7 +67,6 @@ class TestFlattenFunctions:assert result == expecteddef test_flatten_tiktok_report_record_missing_dimensions(self):- """Test flattening record with metrics but no dimensions."""record_with_metrics_only = {"metrics": {"clicks": "100", "impressions": "1000"}}result = TikTokReportResource.transform_analytics_reports([record_with_metrics_only])[0]@@ -78,7 +76,6 @@ class TestFlattenFunctions:assert result == expecteddef test_flatten_tiktok_report_record_missing_metrics(self):- """Test flattening record with dimensions but no metrics."""record_with_dimensions_only = {"dimensions": {"campaign_id": "123", "stat_time_day": "2025-09-27"}}result = TikTokReportResource.transform_analytics_reports([record_with_dimensions_only])[0]@@ -88,14 +85,12 @@ class TestFlattenFunctions:assert result == expecteddef test_flatten_tiktok_report_record_empty_nested_objects(self):- """Test flattening record with empty dimensions and metrics."""record_with_empty_nested: dict[str, dict] = {"dimensions": {}, "metrics": {}}result = TikTokReportResource.transform_analytics_reports([record_with_empty_nested])[0]assert result == {}def test_flatten_tiktok_report_record_non_dict_input(self):- """Test flattening with non-dictionary input."""# Test inputs that cause TypeError (int, None)error_inputs: list[object] = [123, None]for input_value in error_inputs:@@ -109,7 +104,6 @@ class TestFlattenFunctions:assert result == [input_value]def test_flatten_tiktok_reports_batch_processing(self):- """Test batch flattening of multiple TikTok reports."""reports: list[dict[str, Any]] = [{"dimensions": {"campaign_id": "123", "stat_time_day": "2025-09-27"},@@ -133,7 +127,6 @@ class TestFlattenFunctions:assert result == expecteddef test_flatten_tiktok_reports_empty_list(self):- """Test batch flattening with empty list."""result = TikTokReportResource.transform_analytics_reports([])assert result == []@@ -142,7 +135,6 @@ class TestSecondaryGoalNormalization:"""Test suite for secondary goal field normalization."""def test_normalize_secondary_goal_fields_with_dash_values(self):- """Test normalization of secondary goal fields with '-' placeholder values."""report = {"campaign_id": "123","secondary_goal_result": "-",@@ -164,7 +156,6 @@ class TestSecondaryGoalNormalization:assert report == expecteddef test_normalize_secondary_goal_fields_with_valid_values(self):- """Test normalization of secondary goal fields with valid values."""report = {"campaign_id": "123","secondary_goal_result": "50",@@ -181,7 +172,6 @@ class TestSecondaryGoalNormalization:assert report["secondary_goal_result_rate"] == "0.05"def test_normalize_secondary_goal_fields_missing_fields(self):- """Test normalization when secondary goal fields are missing."""report = {"campaign_id": "123","clicks": "100",@@ -195,7 +185,6 @@ class TestSecondaryGoalNormalization:assert "secondary_goal_result_rate" not in reportdef test_normalize_secondary_goal_fields_mixed_values(self):- """Test normalization with mix of dash and valid values."""report = {"campaign_id": "123","secondary_goal_result": "-",@@ -222,7 +211,6 @@ class TestAccountReportsTransformation:"""Test suite for account reports transformation."""def test_transform_account_reports_with_timestamp(self):- """Test account reports transformation with Unix timestamp."""reports = [{"advertiser_id": "123456",@@ -240,7 +228,6 @@ class TestAccountReportsTransformation:assert result[0]["create_time"].tzinfo is not None # Should be timezone-awaredef test_transform_account_reports_with_float_timestamp(self):- """Test account reports transformation with float Unix timestamp."""reports = [{"advertiser_id": "123456",@@ -267,7 +254,6 @@ class TestAccountReportsTransformation:assert result[0]["create_time"] == "2023-09-13T12:00:00Z" # Should remain unchangeddef test_transform_account_reports_without_timestamp(self):- """Test account reports transformation without create_time field."""reports = [{"advertiser_id": "123456",@@ -283,7 +269,6 @@ class TestAccountReportsTransformation:assert "create_time" not in result[0]def test_transform_account_reports_empty_list(self):- """Test account reports transformation with empty list."""result = TikTokReportResource.transform_account_reports([])assert result == []@@ -292,7 +277,6 @@ class TestEntityNormalization:"""Test suite for entity report normalization methods."""def test_normalize_entity_status_without_status_fields(self):- """Test entity status normalization when no status fields exist."""report = {"campaign_id": "123","campaign_name": "Test Campaign",@@ -303,7 +287,6 @@ class TestEntityNormalization:assert report["current_status"] == "ACTIVE"def test_normalize_entity_status_with_existing_current_status(self):- """Test entity status normalization when current_status already exists."""report = {"campaign_id": "123","current_status": "PAUSED",@@ -314,7 +297,6 @@ class TestEntityNormalization:assert report["current_status"] == "PAUSED" # Should remain unchangeddef test_normalize_entity_status_with_status_field(self):- """Test entity status normalization when status field exists."""report = {"campaign_id": "123","status": "ENABLE",@@ -326,7 +308,6 @@ class TestEntityNormalization:assert report["current_status"] == "ACTIVE"def test_normalize_timestamps_with_modify_time(self):- """Test timestamp normalization when modify_time exists."""report = {"campaign_id": "123","create_time": "2023-09-01 10:00:00",@@ -338,7 +319,6 @@ class TestEntityNormalization:assert report["modify_time"] == "2023-09-27 15:30:00" # Should remain unchangeddef test_normalize_timestamps_without_modify_time(self):- """Test timestamp normalization when modify_time is missing but create_time exists."""report = {"campaign_id": "123","create_time": "2023-09-01 10:00:00",@@ -349,7 +329,6 @@ class TestEntityNormalization:assert report["modify_time"] == "2023-09-01 10:00:00" # Should use create_timedef test_normalize_timestamps_without_create_time(self):- """Test timestamp normalization when create_time is missing."""report = {"campaign_id": "123",}@@ -381,7 +360,6 @@ class TestEntityNormalization:assert report["is_comment_disable"] is False # 1 means enabled, so Falsedef test_convert_comment_settings_missing_field(self):- """Test comment settings conversion when field is missing."""report = {"ad_id": "123",}@@ -395,7 +373,6 @@ class TestStreamTransformations:"""Test suite for stream transformations routing."""def test_apply_stream_transformations_report_endpoint(self):- """Test stream transformations for report endpoint."""reports = [{"dimensions": {"campaign_id": "123"},@@ -409,7 +386,6 @@ class TestStreamTransformations:assert result == expecteddef test_apply_stream_transformations_entity_endpoint(self):- """Test stream transformations for entity endpoint."""reports = [{"campaign_id": "123",@@ -425,7 +401,6 @@ class TestStreamTransformations:assert result[0]["current_status"] == "ACTIVE" # Should be added by entity transformationdef test_apply_stream_transformations_account_endpoint(self):- """Test stream transformations for account endpoint."""reports = [{"advertiser_id": "123456",@@ -449,7 +424,6 @@ class TestStreamTransformations:assert result == reportsdef test_apply_stream_transformations_unknown_endpoint(self):- """Test stream transformations for unknown endpoint type."""reports = [{"data": "test"}]# Create a mock EndpointType enum value that's not handled@@ -484,7 +458,6 @@ class TestDateRangeFunctions:])def test_get_incremental_date_range_scenarios(self, name, should_use_incremental, last_value, expected_max_days):- """Test various incremental date range calculation scenarios."""start_date, end_date = TikTokDateRangeManager.get_incremental_range(should_use_incremental, last_value)start_dt = datetime.strptime(start_date, "%Y-%m-%d")@@ -498,7 +471,6 @@ class TestDateRangeFunctions:assert days_diff <= expected_max_days + 1def test_get_incremental_date_range_invalid_date_string(self):- """Test date range calculation with invalid date string."""start_date, end_date = TikTokDateRangeManager.get_incremental_range(True, "invalid_date_string")start_dt = datetime.strptime(start_date, "%Y-%m-%d")@@ -567,7 +539,6 @@ class TestDateRangeFunctions:])def test_generate_date_chunks_scenarios(self, name, start_date, end_date, chunk_days, expected_chunks):- """Test date chunk generation for various scenarios."""chunks = TikTokDateRangeManager.generate_chunks(start_date, end_date, chunk_days)assert len(chunks) == expected_chunks@@ -588,13 +559,11 @@ class TestDateRangeFunctions:assert (next_chunk_start - chunk_end_dt).days == 1def test_generate_date_chunks_invalid_date_format(self):- """Test date chunk generation with invalid date format."""valid_end_date = datetime.now().strftime("%Y-%m-%d")with pytest.raises(ValueError):TikTokDateRangeManager.generate_chunks("invalid-date", valid_end_date, 30)def test_generate_date_chunks_end_before_start(self):- """Test date chunk generation when end date is before start date."""start_date = datetime.now().strftime("%Y-%m-%d")end_date = (datetime.now() - timedelta(days=15)).strftime("%Y-%m-%d")chunks = TikTokDateRangeManager.generate_chunks(start_date, end_date, 30)@@ -615,7 +584,6 @@ class TestTikTokAdsPaginator:return mock_responsedef test_paginator_initialization(self):- """Test paginator initial state."""assert self.paginator.current_page == 1assert self.paginator.has_next_page is Falseassert self.paginator.total_pages == 0@@ -623,7 +591,6 @@ class TestTikTokAdsPaginator:assert self.paginator.page_size == 0def test_update_state_first_page_with_more(self):- """Test paginator update from first page response with more pages."""response_data = {"data": {"page_info": {"page": 1, "page_size": 100, "total_page": 3, "total_number": 250}}}mock_response = self._create_mock_response(response_data)@@ -636,7 +603,6 @@ class TestTikTokAdsPaginator:assert self.paginator.page_size == 100def test_update_state_last_page(self):- """Test paginator update from last page response."""response_data = {"data": {"page_info": {"page": 3, "page_size": 100, "total_page": 3, "total_number": 250}}}mock_response = self._create_mock_response(response_data)@@ -647,7 +613,6 @@ class TestTikTokAdsPaginator:assert self.paginator.total_pages == 3def test_update_state_single_page(self):- """Test paginator update from single page response."""response_data = {"data": {"page_info": {"page": 1, "page_size": 50, "total_page": 1, "total_number": 50}}}mock_response = self._create_mock_response(response_data)@@ -657,7 +622,6 @@ class TestTikTokAdsPaginator:assert self.paginator.current_page == 1def test_update_state_missing_page_info(self):- """Test paginator update with missing page_info."""response_data: dict[str, dict] = {"data": {}}mock_response = self._create_mock_response(response_data)@@ -666,7 +630,6 @@ class TestTikTokAdsPaginator:assert self.paginator.has_next_page is Falsedef test_update_state_missing_data(self):- """Test paginator update with missing data key."""response_data: dict[str, Any] = {}mock_response = self._create_mock_response(response_data)@@ -675,7 +638,6 @@ class TestTikTokAdsPaginator:assert self.paginator.has_next_page is Falsedef test_update_state_exception_handling(self):- """Test paginator handles malformed response gracefully."""malformed_responses = [{"data": "not_a_dict"},{"data": {"page_info": "not_a_dict"}},@@ -755,7 +717,6 @@ class TestTikTokAdsPaginator:])def test_update_state_api_error_codes(self, name, api_code, message, should_be_retryable):- """Test paginator handling of various TikTok API error codes."""mock_response = Mock()mock_response.status_code = 200mock_response.json.return_value = {@@ -784,7 +745,6 @@ class TestTikTokAdsAPIError:"""Test suite for TikTokAdsAPIError exception class."""def test_tiktok_ads_api_error_basic_creation(self):- """Test basic TikTokAdsAPIError creation."""error = TikTokAdsAPIError("Test error message")assert str(error) == "Test error message"@@ -792,7 +752,6 @@ class TestTikTokAdsAPIError:assert error.response is Nonedef test_tiktok_ads_api_error_with_api_code(self):- """Test TikTokAdsAPIError with API code."""error = TikTokAdsAPIError("QPS limit reached", api_code=40100)assert str(error) == "QPS limit reached"@@ -800,7 +759,6 @@ class TestTikTokAdsAPIError:assert error.response is Nonedef test_tiktok_ads_api_error_with_response(self):- """Test TikTokAdsAPIError with response object."""mock_response = Mock()mock_response.status_code = 200@@ -830,7 +788,6 @@ class TestHelperFunctions:])def test_is_report_endpoint(self, endpoint_name, expected_endpoint_type):- """Test identification of report endpoints."""config = TIKTOK_ADS_CONFIG.get(endpoint_name)assert config is not None, f"Endpoint {endpoint_name} not found in config"assert config.endpoint_type == expected_endpoint_typediff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/conftest.py b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/conftest.pyindex cc051d768484..0858511e563b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/conftest.py+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/conftest.py@@ -202,7 +202,6 @@ async def run_external_data_job_workflow(retry_policy=RetryPolicy(maximum_attempts=1),)- # if not ignore_assertions:run = await get_latest_run_if_exists(team_id=team.pk, pipeline_id=external_data_source.pk)assert run is not Nonediff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/stripe/conftest.py b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/stripe/conftest.pyindex 434dc0d3679c..72643d8a0dce 100644--- a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/stripe/conftest.py+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/stripe/conftest.py@@ -67,7 +67,6 @@ class MockStripeAPI:if "starting_after" in query:starting_after = query["starting_after"][0]- # find index of starting_after in filtered_datastarting_after_index = next((i for i, tx in enumerate(filtered_data) if tx["id"] == starting_after), None)if starting_after_index is not None:filtered_data = filtered_data[starting_after_index + 1 :]diff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_end_to_end.py b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_end_to_end.pyindex 5e05a8c7ca7f..d0f0d94251ed 100644--- a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_end_to_end.py+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_end_to_end.py@@ -141,12 +141,6 @@ def pipeline_mode(request, _clean_sourcebatch_tables):_current_pipeline_mode = "non_dlt"-# TODO: remove _KafkaMessageCapture once Postgres producer is fully validated-# class _KafkaMessageCapture:-# ...-# _kafka_capture = _KafkaMessageCapture()--def _get_test_database_url() -> str:"""Build a psycopg-compatible DSN from Django's active test database connection."""from django.db import connection@@ -4074,9 +4068,8 @@ async def test_cdp_producer_push_to_kafka(team, stripe_customer, mock_stripe_climock_kafka_producer.flush = mock.AsyncMock()mock_kafka_producer.close = mock.AsyncMock()- # CDPProducer now uses `async_producer_scope(profile=CYCLOTRON)` from the routing- # module instead of a per-instance `_get_kafka_producer` method; patch the async- # context manager at its import site.+ # CDPProducer takes its producer from `async_producer_scope(profile=CYCLOTRON)` in the routing+ # module, so patch that async context manager at its import site rather than the producer class.@contextlib.asynccontextmanagerasync def _fake_scope(*args, **kwargs):yield mock_kafka_producerdiff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_google_ads_source.py b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_google_ads_source.pyindex 7b19ae270eb6..719451e6d557 100644--- a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_google_ads_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_google_ads_source.py@@ -77,7 +77,6 @@ def service_account_config() -> dict[str, str]:def test_google_ads_source_config_loads(customer_id: str, developer_token: str):- """Test basic case of source configuration loading."""private_key = "private_key"private_key_id = "id"client_email = "[email protected]"@@ -106,7 +105,6 @@ def test_google_ads_source_config_loads(customer_id: str, developer_token: str):def test_google_ads_source_config_handles_customer_id_with_dashes(developer_token: str):- """Test source configuration handles clean up of customer id."""private_key = "private_key"private_key_id = "id"client_email = "[email protected]"diff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_mssql_source.py b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_mssql_source.pyindex 7d0574b4e2cd..ae65936e0d5c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_mssql_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_mssql_source.py@@ -166,7 +166,6 @@ def mssql_source_table(mssql_connection: pymssql.Connection, mssql_config: dict[""")mssql_connection.commit()- # Insert test data_insert_test_data(cursor=cursor, table_name=full_table_name, data=TEST_DATA)yield cursor@@ -248,7 +247,6 @@ class TestEndToEndWorkflow:external_data_source: ExternalDataSource,external_data_schema_full_refresh: ExternalDataSchema,):- """Test that a full refresh sync works as expected."""table_name = f"mssql_{MSSQL_TABLE_NAME}"expected_num_rows = len(TEST_DATA)@@ -282,7 +280,6 @@ class TestEndToEndWorkflow:external_data_source: ExternalDataSource,external_data_schema_incremental: ExternalDataSchema,):- """Test that an incremental sync works as expected."""table_name = f"mssql_{MSSQL_TABLE_NAME}"expected_num_rows = len(TEST_DATA)@@ -362,7 +359,6 @@ class TestEndToEndWorkflow:external_data_source: ExternalDataSource,external_data_schema_incremental_using_created_at_column: ExternalDataSchema,):- """Test that an incremental sync works as expected when using the `created_at` column as the incremental field."""table_name = f"mssql_{MSSQL_TABLE_NAME}"expected_num_rows = len(TEST_DATA)diff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_mysql_source.py b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_mysql_source.pyindex cc26e9a405be..a96ec7649b82 100644--- a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_mysql_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_mysql_source.py@@ -107,7 +107,6 @@ def external_data_schema_full_refresh(external_data_source, team):async def test_mysql_source_full_refresh(team, mysql_source_table, external_data_source, external_data_schema_full_refresh):- """Test that a full refresh sync works as expected."""table_name = f"mysql_{MYSQL_TABLE_NAME}"expected_num_rows = len(TEST_DATA)@@ -220,7 +219,6 @@ def external_data_schema_incremental(external_data_source, team):async def test_mysql_source_incremental(team, mysql_source_table, external_data_source, external_data_schema_incremental, mysql_connection):- """Test that an incremental sync works as expected."""table_name = f"mysql_{MYSQL_TABLE_NAME}"expected_num_rows = len(TEST_DATA)@@ -590,8 +588,6 @@ def test_mysql_narrow_table_chunking(mysql_narrow_table, mysql_config):def test_mysql_wide_table_chunking(mysql_wide_table, mysql_config):- """Test that wide tables use reduced chunk size via dynamic chunking."""-cursor, table_name = mysql_wide_tablelogger = structlog.get_logger()@@ -616,8 +612,6 @@ def test_mysql_wide_table_chunking(mysql_wide_table, mysql_config):def test_mysql_medium_table_chunking(mysql_medium_table, mysql_config):- """Test that medium tables use moderately reduced chunk size."""-cursor, table_name = mysql_medium_tablelogger = structlog.get_logger()@@ -645,8 +639,6 @@ def test_mysql_medium_table_chunking(mysql_medium_table, mysql_config):def test_mysql_very_big_table_chunking(mysql_very_big_table, mysql_config):- """Test that very big tables with many rows use dynamic chunking and process multiple chunks."""-cursor, table_name = mysql_very_big_tablelogger = structlog.get_logger()diff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_postgres_source.py b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_postgres_source.pyindex 80e97957bb05..a9767ddd47de 100644--- a/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_postgres_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/e2e/test_postgres_source.py@@ -182,7 +182,6 @@ async def test_postgres_source_full_refresh(external_data_source: ExternalDataSource,external_data_schema_full_refresh: ExternalDataSchema,):- """Test that a full refresh sync works as expected."""table_name = f"postgres_{POSTGRES_TABLE_NAME}"expected_num_rows = len(TEST_DATA)diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/compute_table_statistics.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/compute_table_statistics.pyindex bda632aafe38..fdd42d70079e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/compute_table_statistics.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/compute_table_statistics.py@@ -210,7 +210,9 @@ def compute_table_statistics_sync(team_id: int, schema_id: uuid.UUID) -> dict[stcapture_statistics_event(team, EVENT_STARTED, event_props)# Locate the committed Delta table. folder_path is schema-derived, so any job for this schema works;- # resource_name mirrors what the pipeline used to name the Delta folder.+ # resource_name must resolve the folder leaf the same way the loader wrote it (see+ # resolve_table_and_folder_names in pipelines/helpers.py), otherwise this reads a path that+ # does not exist and reports no statistics.job = ExternalDataJob.objects.filter(team_id=team_id, schema_id=schema_id).order_by("-created_at").first()if job is None:emit_completed("skipped", reason="no_job")diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.pyindex 73e1abbcfae3..be7cb6f8b197 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py@@ -262,7 +262,7 @@ def _maybe_repartition_table(inputs: RepartitionActivityInputs, logger: Filterin# Log the rollout-flag verdict (and the recorded/budget sizes) so it's clear from the Syncs UI why a# table does or doesn't repartition — a disabled flag is the most common reason for a no-op. Note- # `max_partition_bytes` here is the last *recorded* value (can be stale); the gate no longer trusts+ # `max_partition_bytes` here is the last *recorded* value (can be stale); the gate does not trust# it, the live size is read below. Evaluate the flag once and thread the result into the# pre-extraction detection path so it isn't re-evaluated inside maybe_flag_for_repartition.enabled = is_auto_repartition_enabled(schema)diff --git a/products/warehouse_sources/backend/test/utils.py b/products/warehouse_sources/backend/test/utils.pyindex 1c5ab5d77821..c6af993350eb 100644--- a/products/warehouse_sources/backend/test/utils.py+++ b/products/warehouse_sources/backend/test/utils.py@@ -50,7 +50,6 @@ def create_data_warehouse_table_from_csv(},)- # Read CSVdf = pd.read_csv(csv_path)# Append XDIST_SUFFIX to test bucket if it existsdiff --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 da58ef335322..b277812c70d7 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@@ -2071,7 +2071,6 @@ class TestExternalDataSource(APIBaseTest):assert response.status_code == 201def test_create_external_data_source_bigquery_removes_project_id_prefix(self):- """Test we remove the `project_id` prefix of a `dataset_id`."""with (patch("products.warehouse_sources.backend.temporal.data_imports.sources.bigquery.source.BigQuerySource.get_schemas",@@ -2127,7 +2126,6 @@ class TestExternalDataSource(APIBaseTest):assert source_model.job_inputs["dataset_id"] == "my_project.my_dataset"def test_create_external_data_source_missing_required_bigquery_job_input(self):- """Test we fail source creation when missing inputs."""response = self.client.post(f"/api/environments/{self.team.pk}/external_data_sources/",data={@@ -5820,7 +5818,6 @@ class TestExternalDataSource(APIBaseTest):return_value=(True, None),)def test_update_with_new_password_updates_password(self, mock_validate_credentials):- """Test that explicitly providing a new password does update it."""source = ExternalDataSource.objects.create(team_id=self.team.pk,source_id=str(uuid.uuid4()),@@ -7665,7 +7662,6 @@ class TestExternalDataSource(APIBaseTest):mock_validate_credentials.assert_called_once()def test_snowflake_auth_type_create_and_update(self):- """Test that we can create and update the auth type for a Snowflake source"""with (patch("products.warehouse_sources.backend.temporal.data_imports.sources.snowflake.source.SnowflakeSource.validate_credentials",@@ -7783,7 +7779,6 @@ class TestExternalDataSource(APIBaseTest):assert job_inputs["auth_type"]["private_key"] == "my_private_key"def test_bigquery_create_and_update(self):- """Test that we can create and update the config for a BigQuery source"""with (patch("products.warehouse_sources.backend.temporal.data_imports.sources.bigquery.source.BigQuerySource.validate_credentials",@@ -8067,7 +8062,6 @@ class TestExternalDataSource(APIBaseTest):assert response.json()["message"] != limit_messagedef test_revenue_analytics_config_created_automatically(self):- """Test that revenue analytics config is created automatically when external data source is created."""source = self._create_external_data_source()# Config should be created automatically@@ -8079,7 +8073,6 @@ class TestExternalDataSource(APIBaseTest):assert config.include_invoiceless_charges is Truedef test_revenue_analytics_config_safe_property(self):- """Test that the safe property always returns a config even if it doesn't exist."""source = self._create_external_data_source()# Delete the config to test fallback@@ -8092,7 +8085,6 @@ class TestExternalDataSource(APIBaseTest):assert config.enabled is True # Stripe should be enabled by defaultdef test_revenue_analytics_config_in_api_response(self):- """Test that revenue analytics config is included in API responses."""source = self._create_external_data_source()response = self.client.get(f"/api/environments/{self.team.pk}/external_data_sources/{source.pk}")@@ -8105,7 +8097,6 @@ class TestExternalDataSource(APIBaseTest):assert config_data["include_invoiceless_charges"] is Truedef test_update_revenue_analytics_config(self):- """Test updating revenue analytics config via PATCH endpoint."""source = self._create_external_data_source()response = self.client.patch(@@ -8132,7 +8123,6 @@ class TestExternalDataSource(APIBaseTest):assert config.include_invoiceless_charges is Falsedef test_revenue_analytics_config_partial_update(self):- """Test partial update of revenue analytics config."""source = self._create_external_data_source()response = self.client.patch(@@ -8149,7 +8139,6 @@ class TestExternalDataSource(APIBaseTest):assert config.include_invoiceless_charges is True # Should remain unchangeddef test_revenue_analytics_config_queryset_optimization(self):- """Test that the manager uses select_related for efficient queries."""self._create_external_data_source()self._create_external_data_source()@@ -8199,7 +8188,6 @@ class TestExternalDataSource(APIBaseTest):assert DataWarehouseJoin.objects.filter(team=self.team, source_table_name=view_name, deleted=True).exists()def test_create_external_data_source_rejects_invalid_prefix(self):- """Test that invalid characters in prefix are rejected."""invalid_prefixes = [("[email protected]", "@"),("test-prefix", "hyphen"),@@ -8247,7 +8235,6 @@ class TestExternalDataSource(APIBaseTest):return_value=(True, None),)def test_create_external_data_source_accepts_valid_prefix(self, _mock_validate):- """Test that valid prefixes are accepted."""valid_prefixes = ["valid_prefix","_starts_with_underscore",diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_source_access_control.py b/products/warehouse_sources/backend/tests/api/test_external_data_source_access_control.pyindex ea6ce6ad2343..ec605e598068 100644--- a/products/warehouse_sources/backend/tests/api/test_external_data_source_access_control.py+++ b/products/warehouse_sources/backend/tests/api/test_external_data_source_access_control.py@@ -154,7 +154,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):# --- Viewer Access Level Tests ---def test_viewer_can_list_sources(self):- """Test that a user with viewer access can list sources"""self._create_access_control(self.viewer_user, access_level="viewer")self.client.force_login(self.viewer_user)@@ -163,7 +162,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertEqual(response.status_code, status.HTTP_200_OK)def test_viewer_can_retrieve_source(self):- """Test that a user with viewer access can retrieve a source"""self._create_access_control(self.viewer_user, access_level="viewer")self.client.force_login(self.viewer_user)@@ -173,7 +171,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertEqual(response.json()["id"], str(self.source.id))def test_viewer_cannot_delete_source(self):- """Test that a user with viewer access cannot delete a source"""self._create_access_control(self.viewer_user, access_level="viewer")self.client.force_login(self.viewer_user)@@ -183,7 +180,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertIn("editor", response.json()["detail"].lower())def test_viewer_cannot_update_source(self):- """Test that a user with viewer access cannot update a source"""self._create_access_control(self.viewer_user, access_level="viewer")self.client.force_login(self.viewer_user)@@ -195,7 +191,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)def test_viewer_cannot_reload_source(self):- """Test that a user with viewer access cannot reload a source"""self._create_access_control(self.viewer_user, access_level="viewer")self.client.force_login(self.viewer_user)@@ -206,7 +201,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):# --- Editor Access Level Tests ---def test_editor_can_list_sources(self):- """Test that a user with editor access can list sources"""self._create_access_control(self.editor_user, access_level="editor")self.client.force_login(self.editor_user)@@ -215,7 +209,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertEqual(response.status_code, status.HTTP_200_OK)def test_editor_can_retrieve_source(self):- """Test that a user with editor access can retrieve a source"""self._create_access_control(self.editor_user, access_level="editor")self.client.force_login(self.editor_user)@@ -224,7 +217,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertEqual(response.status_code, status.HTTP_200_OK)def test_editor_can_update_source(self):- """Test that a user with editor access can update a source"""self._create_access_control(self.editor_user, access_level="editor")self.client.force_login(self.editor_user)@@ -238,7 +230,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertEqual(self.source.description, "Updated description")def test_editor_can_delete_source(self):- """Test that a user with editor access can delete a source"""self._create_access_control(self.editor_user, access_level="editor")self.client.force_login(self.editor_user)@@ -261,7 +252,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)def test_none_access_cannot_retrieve_source(self):- """Test that a user with no access cannot retrieve a source"""self._create_access_control(self.no_access_user, access_level="none")self.client.force_login(self.no_access_user)@@ -272,7 +262,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):# --- Project Default Access Control Tests ---def test_project_default_none_blocks_list_without_specific_access(self):- """Test that project-default 'none' access blocks list for users without specific object access"""self._create_project_default_access_control(access_level="none")self.client.force_login(self.viewer_user)@@ -282,7 +271,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)def test_explicit_access_overrides_project_default_none(self):- """Test that explicit user access overrides project-default 'none'"""self._create_project_default_access_control(access_level="none")self._create_access_control(self.viewer_user, access_level="viewer")@@ -295,7 +283,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):# --- Object-Level Access Control Tests ---def test_specific_source_access_with_none_resource_access(self):- """Test that a user can have access to specific sources only"""# Create another sourcesource2 = self._create_external_data_source()@@ -321,7 +308,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)def test_filtered_list_with_mixed_access(self):- """Test that list only returns sources the user has access to"""# Create another source that viewer won't have access toself._create_external_data_source()@@ -746,8 +732,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):# --- Organization Admin Tests ---def test_org_admin_has_full_access(self):- """Test that organization admins have full access to sources"""- # Set project-default to noneself._create_project_default_access_control(access_level="none")# Make user an org admin@@ -769,15 +753,12 @@ class TestExternalDataSourceAccessControl(APIBaseTest):# --- Role-Based Access Tests ---def test_role_grants_editor_access(self):- """Test that roles can be used to grant source access"""- # Set project-default to noneself._create_project_default_access_control(access_level="none")# Create a role with editor access to sourcesrole = Role.objects.create(name="Source Editors", organization=self.organization)RoleMembership.objects.create(user=self.editor_user, role=role)- # Grant the role editor accessAccessControl.objects.create(team=self.team, resource="external_data_source", access_level="editor", role=role)self.client.force_login(self.editor_user)@@ -792,15 +773,12 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)def test_role_grants_viewer_access(self):- """Test that roles can grant viewer access"""- # Set project-default to noneself._create_project_default_access_control(access_level="none")# Create a role with viewer accessrole = Role.objects.create(name="Source Viewers", organization=self.organization)RoleMembership.objects.create(user=self.viewer_user, role=role)- # Grant the role viewer accessAccessControl.objects.create(team=self.team, resource="external_data_source", access_level="viewer", role=role)self.client.force_login(self.viewer_user)@@ -817,8 +795,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):# --- Creator Access Tests ---def test_creator_can_delete_other_users_blocked_source(self):- """Test that a creator can delete their source even when others can't access it"""- # Create a source by editor_usersource = self._create_external_data_source(created_by=self.editor_user)# Set project-default to none (blocks access for everyone)@@ -842,8 +818,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)def test_viewer_cannot_delete_regardless_of_creator(self):- """Test that viewer resource access cannot delete, regardless of being creator or not"""- # Create a source by viewer_usersource = self._create_external_data_source(created_by=self.viewer_user)# Give viewer_user only viewer resource access@@ -857,8 +831,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)def test_creator_can_modify_access_controls(self):- """Test that the creator can modify access controls for their sources"""- # Create a source by editor_usersource = self._create_external_data_source(created_by=self.editor_user)uac = UserAccessControl(self.editor_user, self.team)@@ -869,7 +841,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):# --- user_access_level Response Field Tests ---def test_user_access_level_in_list_response(self):- """Test that user_access_level is included in list response"""self._create_access_control(self.viewer_user, access_level="viewer")self.client.force_login(self.viewer_user)@@ -881,7 +852,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):self.assertIn("user_access_level", results[0])def test_user_access_level_in_detail_response(self):- """Test that user_access_level is included in detail response"""self._create_access_control(self.viewer_user, access_level="viewer")self.client.force_login(self.viewer_user)@@ -893,7 +863,6 @@ class TestExternalDataSourceAccessControl(APIBaseTest):# --- Manager Access Tests ---def test_manager_can_access_access_controls_endpoint(self):- """Test that a user with manager access can access the access_controls endpoint"""self._create_access_control(self.editor_user, access_level="manager")self.client.force_login(self.editor_user)