diff --git a/cosmos/profiles/bigquery/service_account_keyfile_dict.py b/cosmos/profiles/bigquery/service_account_keyfile_dict.py index 1c0d1391f..e84587faf 100644 --- a/cosmos/profiles/bigquery/service_account_keyfile_dict.py +++ b/cosmos/profiles/bigquery/service_account_keyfile_dict.py @@ -56,10 +56,7 @@ def mock_profile(self) -> dict[str, Any | None]: "Generates mock profile. Defaults `threads` to 1." parent_mock_profile = super().mock_profile - return { - **parent_mock_profile, - "threads": 1, - } + return {**parent_mock_profile, "threads": 1, "keyfile_json": None} def transform_keyfile_json(self, keyfile_json: str | dict[str, str]) -> dict[str, str]: """ diff --git a/tests/profiles/bigquery/test_bq_service_account_keyfile_dict.py b/tests/profiles/bigquery/test_bq_service_account_keyfile_dict.py index 8a260ec2f..0647e6800 100644 --- a/tests/profiles/bigquery/test_bq_service_account_keyfile_dict.py +++ b/tests/profiles/bigquery/test_bq_service_account_keyfile_dict.py @@ -72,6 +72,22 @@ def test_profile(mock_bigquery_conn_with_dict: Connection): assert profile_mapping.profile == expected +def test_mock_profile(mock_bigquery_conn_with_dict: Connection): + """ + Tests profile mock for keyfile_json is None. Giving keyfile_json a value will crash dbt ls. + """ + profile_mapping = GoogleCloudServiceAccountDictProfileMapping(mock_bigquery_conn_with_dict, {}) + expected = { + "type": "bigquery", + "method": "service-account-json", + "project": "mock_value", + "dataset": "mock_value", + "threads": 1, + "keyfile_json": None, + } + assert profile_mapping.mock_profile == expected + + def test_profile_env_vars(mock_bigquery_conn_with_dict: Connection): """ Tests that the environment variables get set correctly.