Skip to content

Commit 69f02cd

Browse files
Lint
1 parent dd04d92 commit 69f02cd

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

src/snowflake/connector/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def _get_private_bytes_from_file(
359359
"enable_single_use_refresh_tokens": (
360360
False,
361361
bool,
362-
)
362+
),
363363
}
364364

365365
APPLICATION_RE = re.compile(r"[\w\d_]+")

test/unit/test_auth_oauth_auth_code.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved.
44
#
55

6+
from unittest.mock import patch
7+
68
import pytest
9+
710
from snowflake.connector.auth import AuthByOauthCode
811
from snowflake.connector.network import OAUTH_AUTHORIZATION_CODE
9-
from unittest.mock import patch
1012

1113

1214
def test_auth_oauth_auth_code_oauth_type():
@@ -24,6 +26,7 @@ def test_auth_oauth_auth_code_oauth_type():
2426
auth.update_body(body)
2527
assert body["data"]["OAUTH_TYPE"] == "authorization_code"
2628

29+
2730
@pytest.mark.parametrize("rtr_enabled", [True, False])
2831
def test_auth_oauth_auth_code_single_use_refresh_tokens(rtr_enabled: bool):
2932
"""Verifies that the enable_single_use_refresh_tokens option is plumbed into the authz code request."""
@@ -38,12 +41,26 @@ def test_auth_oauth_auth_code_single_use_refresh_tokens(rtr_enabled: bool):
3841
pkce_enabled=False,
3942
enable_single_use_refresh_tokens=rtr_enabled,
4043
)
44+
4145
def fake_get_request_token_response(_, fields: dict[str, str]):
4246
if rtr_enabled:
4347
assert fields.get("enable_single_use_refresh_tokens") == "true"
4448
else:
4549
assert "enable_single_use_refresh_tokens" not in fields
4650
return ("access_token", "refresh_token")
47-
with patch("snowflake.connector.auth.AuthByOauthCode._do_authorization_request", return_value="abc"):
48-
with patch("snowflake.connector.auth.AuthByOauthCode._get_request_token_response", side_effect=fake_get_request_token_response):
49-
auth.prepare(conn=None, authenticator=OAUTH_AUTHORIZATION_CODE, service_name=None, account="acc", user="user")
51+
52+
with patch(
53+
"snowflake.connector.auth.AuthByOauthCode._do_authorization_request",
54+
return_value="abc",
55+
):
56+
with patch(
57+
"snowflake.connector.auth.AuthByOauthCode._get_request_token_response",
58+
side_effect=fake_get_request_token_response,
59+
):
60+
auth.prepare(
61+
conn=None,
62+
authenticator=OAUTH_AUTHORIZATION_CODE,
63+
service_name=None,
64+
account="acc",
65+
user="user",
66+
)

test/unit/test_connection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,9 @@ def test_toml_connection_params_are_plumbed_into_authbyworkloadidentity(
690690

691691

692692
@pytest.mark.parametrize("rtr_enabled", [True, False])
693-
def test_single_use_refresh_tokens_option_is_plumbed_into_authbyauthcode(monkeypatch, rtr_enabled: bool):
693+
def test_single_use_refresh_tokens_option_is_plumbed_into_authbyauthcode(
694+
monkeypatch, rtr_enabled: bool
695+
):
694696
with monkeypatch.context() as m:
695697
m.setattr(
696698
"snowflake.connector.SnowflakeConnection._authenticate", lambda *_: None

0 commit comments

Comments
 (0)