Skip to content

Commit 42d09d9

Browse files
cherry-pick #2515
1 parent 75646bb commit 42d09d9

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
@@ -1091,11 +1091,11 @@ def test_disable_query_context_cache(conn_cnx) -> None:
10911091

10921092

10931093
@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+
):
10991099
import tomlkit
11001100

11011101
doc = tomlkit.document()
@@ -1105,16 +1105,16 @@ def test_connection_name_loading(monkeypatch, db_parameters, tmp_path, mode):
11051105
# If anything unexpected fails here, don't want to expose password
11061106
for k, v in db_parameters.items():
11071107
default_con[k] = v
1108-
doc["default"] = default_con
1108+
doc[connection_name] = default_con
11091109
with monkeypatch.context() as m:
11101110
if mode == "env":
1111-
m.setenv("SF_CONNECTIONS", tomlkit.dumps(doc))
1111+
m.setenv("SNOWFLAKE_CONNECTIONS", tomlkit.dumps(doc))
11121112
else:
11131113
tmp_connections_file = tmp_path / "connections.toml"
11141114
tmp_connections_file.write_text(tomlkit.dumps(doc))
11151115
tmp_connections_file.chmod(stat.S_IRUSR | stat.S_IWUSR)
11161116
with snowflake.connector.connect(
1117-
connection_name="default",
1117+
connection_name=connection_name,
11181118
connections_file_path=tmp_connections_file,
11191119
) as conn:
11201120
with conn.cursor() as cur:
@@ -1129,7 +1129,8 @@ def test_connection_name_loading(monkeypatch, db_parameters, tmp_path, mode):
11291129

11301130

11311131
@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):
11331134
import tomlkit
11341135

11351136
doc = tomlkit.document()
@@ -1138,10 +1139,10 @@ def test_default_connection_name_loading(monkeypatch, db_parameters):
11381139
# If anything unexpected fails here, don't want to expose password
11391140
for k, v in db_parameters.items():
11401141
default_con[k] = v
1141-
doc["default"] = default_con
1142+
doc[connection_name] = default_con
11421143
with monkeypatch.context() as m:
11431144
m.setenv("SNOWFLAKE_CONNECTIONS", tomlkit.dumps(doc))
1144-
m.setenv("SNOWFLAKE_DEFAULT_CONNECTION_NAME", "default")
1145+
m.setenv("SNOWFLAKE_DEFAULT_CONNECTION_NAME", connection_name)
11451146
with snowflake.connector.connect() as conn:
11461147
with conn.cursor() as cur:
11471148
assert cur.execute("select 1;").fetchall() == [

0 commit comments

Comments
 (0)