Skip to content

Commit 2542058

Browse files
Isolate connection name loading tests (#2515)
1 parent 009c55a commit 2542058

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

test/integ/test_connection.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,11 +1236,11 @@ def test_disable_query_context_cache(conn_cnx) -> None:
12361236

12371237

12381238
@pytest.mark.skipolddriver
1239-
@pytest.mark.parametrize(
1240-
"mode",
1241-
("file", "env"),
1242-
)
1243-
def test_connection_name_loading(monkeypatch, db_parameters, tmp_path, mode):
1239+
@pytest.mark.parametrize("mode", ("file", "env"))
1240+
@pytest.mark.parametrize("connection_name", ["default", "custom_connection_for_test"])
1241+
def test_connection_name_loading(
1242+
monkeypatch, db_parameters, tmp_path, mode, connection_name
1243+
):
12441244
import tomlkit
12451245

12461246
doc = tomlkit.document()
@@ -1250,16 +1250,16 @@ def test_connection_name_loading(monkeypatch, db_parameters, tmp_path, mode):
12501250
# If anything unexpected fails here, don't want to expose password
12511251
for k, v in db_parameters.items():
12521252
default_con[k] = v
1253-
doc["default"] = default_con
1253+
doc[connection_name] = default_con
12541254
with monkeypatch.context() as m:
12551255
if mode == "env":
1256-
m.setenv("SF_CONNECTIONS", tomlkit.dumps(doc))
1256+
m.setenv("SNOWFLAKE_CONNECTIONS", tomlkit.dumps(doc))
12571257
else:
12581258
tmp_connections_file = tmp_path / "connections.toml"
12591259
tmp_connections_file.write_text(tomlkit.dumps(doc))
12601260
tmp_connections_file.chmod(stat.S_IRUSR | stat.S_IWUSR)
12611261
with snowflake.connector.connect(
1262-
connection_name="default",
1262+
connection_name=connection_name,
12631263
connections_file_path=tmp_connections_file,
12641264
) as conn:
12651265
with conn.cursor() as cur:
@@ -1274,7 +1274,8 @@ def test_connection_name_loading(monkeypatch, db_parameters, tmp_path, mode):
12741274

12751275

12761276
@pytest.mark.skipolddriver
1277-
def test_default_connection_name_loading(monkeypatch, db_parameters):
1277+
@pytest.mark.parametrize("connection_name", ["default", "custom_connection_for_test"])
1278+
def test_default_connection_name_loading(monkeypatch, db_parameters, connection_name):
12781279
import tomlkit
12791280

12801281
doc = tomlkit.document()
@@ -1283,10 +1284,10 @@ def test_default_connection_name_loading(monkeypatch, db_parameters):
12831284
# If anything unexpected fails here, don't want to expose password
12841285
for k, v in db_parameters.items():
12851286
default_con[k] = v
1286-
doc["default"] = default_con
1287+
doc[connection_name] = default_con
12871288
with monkeypatch.context() as m:
12881289
m.setenv("SNOWFLAKE_CONNECTIONS", tomlkit.dumps(doc))
1289-
m.setenv("SNOWFLAKE_DEFAULT_CONNECTION_NAME", "default")
1290+
m.setenv("SNOWFLAKE_DEFAULT_CONNECTION_NAME", connection_name)
12901291
with snowflake.connector.connect() as conn:
12911292
with conn.cursor() as cur:
12921293
assert cur.execute("select 1;").fetchall() == [

0 commit comments

Comments
 (0)