Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pczajka committed Jan 7, 2025
1 parent c03ee98 commit 9538c03
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/test_snow_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,32 @@ def test_returns_nice_error_in_case_of_missing_master_token(runner):
"When using a session token, you must provide the corresponding master token"
in result.output
)


@mock.patch("snowflake.connector.connect")
@pytest.mark.parametrize("feature_flag", [None, True, False])
def test_internal_application_data_is_sent_if_feature_flag_is_set(
mock_connect, runner, feature_flag
):
expected_kwargs = {
"application": "SNOWCLI.SQL",
"database": "db_for_test",
"schema": "test_public",
"role": "test_role",
"warehouse": "xs",
"password": "dummy_password",
"application_name": "snowcli",
}
env = {}
if feature_flag is not None:
env["SNOWFLAKE_CLI_FEATURES_ENABLE_SEPARATE_AUTHENTICATION_POLICY_ID"] = str(
feature_flag
)
if feature_flag:
# internal app data should be disabled by default
expected_kwargs["internal_application_name"] = "SNOWFLAKE_CLI"
expected_kwargs["internal_application_version"] = "0.0.0-test_patched"
with mock.patch.dict(os.environ, env):
result = runner.invoke(["sql", "-q", "select 1"])
assert result.exit_code == 0
mock_connect.assert_called_once_with(**expected_kwargs)

0 comments on commit 9538c03

Please sign in to comment.