@@ -1105,11 +1105,11 @@ async def test_disable_query_context_cache(conn_cnx) -> None:
1105
1105
1106
1106
1107
1107
@pytest .mark .skipolddriver
1108
- @pytest .mark .parametrize (
1109
- "mode" ,
1110
- ( "file" , "env" ),
1111
- )
1112
- async def test_connection_name_loading ( monkeypatch , db_parameters , tmp_path , mode ):
1108
+ @pytest .mark .parametrize ("mode" , ( "file" , "env" ))
1109
+ @ pytest . mark . parametrize ( "connection_name" , [ "default" , "custom_connection_for_test" ])
1110
+ async def test_connection_name_loading (
1111
+ monkeypatch , db_parameters , tmp_path , mode , connection_name
1112
+ ):
1113
1113
import tomlkit
1114
1114
1115
1115
doc = tomlkit .document ()
@@ -1119,16 +1119,16 @@ async def test_connection_name_loading(monkeypatch, db_parameters, tmp_path, mod
1119
1119
# If anything unexpected fails here, don't want to expose password
1120
1120
for k , v in db_parameters .items ():
1121
1121
default_con [k ] = v
1122
- doc ["default" ] = default_con
1122
+ doc [connection_name ] = default_con
1123
1123
with monkeypatch .context () as m :
1124
1124
if mode == "env" :
1125
- m .setenv ("SF_CONNECTIONS " , tomlkit .dumps (doc ))
1125
+ m .setenv ("SNOWFLAKE_CONNECTIONS " , tomlkit .dumps (doc ))
1126
1126
else :
1127
1127
tmp_connections_file = tmp_path / "connections.toml"
1128
1128
tmp_connections_file .write_text (tomlkit .dumps (doc ))
1129
1129
tmp_connections_file .chmod (stat .S_IRUSR | stat .S_IWUSR )
1130
1130
async with snowflake .connector .aio .SnowflakeConnection (
1131
- connection_name = "default" ,
1131
+ connection_name = connection_name ,
1132
1132
connections_file_path = tmp_connections_file ,
1133
1133
) as conn :
1134
1134
async with conn .cursor () as cur :
@@ -1143,7 +1143,10 @@ async def test_connection_name_loading(monkeypatch, db_parameters, tmp_path, mod
1143
1143
1144
1144
1145
1145
@pytest .mark .skipolddriver
1146
- async def test_default_connection_name_loading (monkeypatch , db_parameters ):
1146
+ @pytest .mark .parametrize ("connection_name" , ["default" , "custom_connection_for_test" ])
1147
+ async def test_default_connection_name_loading (
1148
+ monkeypatch , db_parameters , connection_name
1149
+ ):
1147
1150
import tomlkit
1148
1151
1149
1152
doc = tomlkit .document ()
@@ -1152,10 +1155,10 @@ async def test_default_connection_name_loading(monkeypatch, db_parameters):
1152
1155
# If anything unexpected fails here, don't want to expose password
1153
1156
for k , v in db_parameters .items ():
1154
1157
default_con [k ] = v
1155
- doc ["default" ] = default_con
1158
+ doc [connection_name ] = default_con
1156
1159
with monkeypatch .context () as m :
1157
1160
m .setenv ("SNOWFLAKE_CONNECTIONS" , tomlkit .dumps (doc ))
1158
- m .setenv ("SNOWFLAKE_DEFAULT_CONNECTION_NAME" , "default" )
1161
+ m .setenv ("SNOWFLAKE_DEFAULT_CONNECTION_NAME" , connection_name )
1159
1162
async with snowflake .connector .aio .SnowflakeConnection () as conn :
1160
1163
async with conn .cursor () as cur :
1161
1164
assert await (await cur .execute ("select 1;" )).fetchall () == [
0 commit comments