@@ -1091,11 +1091,11 @@ def test_disable_query_context_cache(conn_cnx) -> None:
1091
1091
1092
1092
1093
1093
@pytest .mark .skipolddriver
1094
- @pytest .mark .parametrize (
1095
- "mode" ,
1096
- ( "file" , "env" ),
1097
- )
1098
- def test_connection_name_loading ( monkeypatch , db_parameters , tmp_path , mode ):
1094
+ @pytest .mark .parametrize ("mode" , ( "file" , "env" ))
1095
+ @ pytest . mark . parametrize ( "connection_name" , [ "default" , "custom_connection_for_test" ])
1096
+ def test_connection_name_loading (
1097
+ monkeypatch , db_parameters , tmp_path , mode , connection_name
1098
+ ):
1099
1099
import tomlkit
1100
1100
1101
1101
doc = tomlkit .document ()
@@ -1105,16 +1105,16 @@ def test_connection_name_loading(monkeypatch, db_parameters, tmp_path, mode):
1105
1105
# If anything unexpected fails here, don't want to expose password
1106
1106
for k , v in db_parameters .items ():
1107
1107
default_con [k ] = v
1108
- doc ["default" ] = default_con
1108
+ doc [connection_name ] = default_con
1109
1109
with monkeypatch .context () as m :
1110
1110
if mode == "env" :
1111
- m .setenv ("SF_CONNECTIONS " , tomlkit .dumps (doc ))
1111
+ m .setenv ("SNOWFLAKE_CONNECTIONS " , tomlkit .dumps (doc ))
1112
1112
else :
1113
1113
tmp_connections_file = tmp_path / "connections.toml"
1114
1114
tmp_connections_file .write_text (tomlkit .dumps (doc ))
1115
1115
tmp_connections_file .chmod (stat .S_IRUSR | stat .S_IWUSR )
1116
1116
with snowflake .connector .connect (
1117
- connection_name = "default" ,
1117
+ connection_name = connection_name ,
1118
1118
connections_file_path = tmp_connections_file ,
1119
1119
) as conn :
1120
1120
with conn .cursor () as cur :
@@ -1129,7 +1129,8 @@ def test_connection_name_loading(monkeypatch, db_parameters, tmp_path, mode):
1129
1129
1130
1130
1131
1131
@pytest .mark .skipolddriver
1132
- def test_default_connection_name_loading (monkeypatch , db_parameters ):
1132
+ @pytest .mark .parametrize ("connection_name" , ["default" , "custom_connection_for_test" ])
1133
+ def test_default_connection_name_loading (monkeypatch , db_parameters , connection_name ):
1133
1134
import tomlkit
1134
1135
1135
1136
doc = tomlkit .document ()
@@ -1138,10 +1139,10 @@ def test_default_connection_name_loading(monkeypatch, db_parameters):
1138
1139
# If anything unexpected fails here, don't want to expose password
1139
1140
for k , v in db_parameters .items ():
1140
1141
default_con [k ] = v
1141
- doc ["default" ] = default_con
1142
+ doc [connection_name ] = default_con
1142
1143
with monkeypatch .context () as m :
1143
1144
m .setenv ("SNOWFLAKE_CONNECTIONS" , tomlkit .dumps (doc ))
1144
- m .setenv ("SNOWFLAKE_DEFAULT_CONNECTION_NAME" , "default" )
1145
+ m .setenv ("SNOWFLAKE_DEFAULT_CONNECTION_NAME" , connection_name )
1145
1146
with snowflake .connector .connect () as conn :
1146
1147
with conn .cursor () as cur :
1147
1148
assert cur .execute ("select 1;" ).fetchall () == [
0 commit comments