diff --git a/schemachange/config/get_merged_config.py b/schemachange/config/get_merged_config.py index b056ee2..0d4789d 100644 --- a/schemachange/config/get_merged_config.py +++ b/schemachange/config/get_merged_config.py @@ -44,8 +44,6 @@ def get_merged_config( env_kwargs: dict[str, str] = get_env_kwargs() logger.debug("env_kwargs", **env_kwargs) - connection_name = env_kwargs.pop("connection_name", None) - cli_kwargs = parse_cli_args(sys.argv[1:]) logger.debug("cli_kwargs", **cli_kwargs) @@ -55,8 +53,9 @@ def get_merged_config( file_path=cli_kwargs.pop("connections_file_path", None) ) + connection_name = cli_kwargs.pop("connection_name", None) if connection_name is None: - connection_name = cli_kwargs.pop("connection_name", None) + connection_name = env_kwargs.pop("connection_name", None) config_folder = validate_directory(path=cli_kwargs.pop("config_folder", ".")) config_file_name = cli_kwargs.pop("config_file_name") diff --git a/tests/config/test_get_merged_config.py b/tests/config/test_get_merged_config.py index b86a5d1..8338ab5 100644 --- a/tests/config/test_get_merged_config.py +++ b/tests/config/test_get_merged_config.py @@ -365,12 +365,12 @@ def get_connection_from_toml(file_path: Path, connection_name: str) -> dict: "snowflake_warehouse": "cli_snowflake_warehouse", "snowflake_database": "cli_snowflake_database", "snowflake_schema": "cli_snowflake_schema", - "snowflake_authenticator": "env_snowflake_authenticator", + "snowflake_authenticator": "cli_snowflake_authenticator", "snowflake_password": "env_snowflake_password", - "snowflake_private_key_path": "env_snowflake_private_key_path", + "snowflake_private_key_path": "cli_snowflake_private_key_path", "snowflake_token_path": "cli_snowflake_token_path", "connections_file_path": Path("cli_connections_file_path"), - "connection_name": "env_connection_name", + "connection_name": "cli_connection_name", "change_history_table": "cli_change_history_table", "create_change_history_table": False, "autocommit": False, @@ -756,8 +756,8 @@ def test_invalid_config_folder(mock_parse_cli_args, _): "snowflake_warehouse": "snowflake-warehouse-from-cli", "snowflake_database": "snowflake-database-from-cli", "snowflake_schema": "snowflake-schema-from-cli", - "snowflake_authenticator": "env_snowflake_authenticator", - "snowflake_private_key_path": "env_snowflake_private_key_path", + "snowflake_authenticator": "snowflake-authenticator-from-cli", + "snowflake_private_key_path": "snowflake-private-key-path-from-cli", "snowflake_token_path": "snowflake-token-path-from-cli", "change_history_table": "change-history-table-from-cli", "config_vars": { @@ -772,7 +772,7 @@ def test_invalid_config_folder(mock_parse_cli_args, _): "query_tag": "query-tag-from-cli", "snowflake_oauth_token": "env_snowflake_token", "oauth_config": {"oauth_config_variable": "cli_oauth_config_value"}, - "connection_name": "anotherconnection", + "connection_name": "myaltconnection", "connections_file_path": assets_path / "alt-connections.toml", "snowflake_password": "env_snowflake_password", }, diff --git a/tests/test_main.py b/tests/test_main.py index 178f2aa..84180f8 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -361,8 +361,8 @@ def get_connection_from_toml(file_path: Path, connection_name: str) -> dict: "snowflake_schema": get_snowflake_identifier_string( "snowflake-schema-from-cli", "placeholder" ), - "snowflake_authenticator": "snowflake_jwt", - "snowflake_private_key_path": assets_path / "alt_private_key.txt", + "snowflake_authenticator": "externalbrowser", + "snowflake_private_key_path": assets_path / "private_key.txt", "change_history_table": ChangeHistoryTable( database_name="db", schema_name="schema",