-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove unnecessary patching, test for missing email_domain
- Loading branch information
1 parent
97a2cea
commit afaa90b
Showing
1 changed file
with
39 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,45 +26,48 @@ def test_source_close_cleans_tmp(snowflake_connect, tmp_path): | |
|
||
@patch("snowflake.connector.connect") | ||
def test_user_identifiers_email_as_identifier(snowflake_connect, tmp_path): | ||
with patch("tempfile.tempdir", str(tmp_path)): | ||
source = SnowflakeQueriesSource.create( | ||
{ | ||
"connection": { | ||
"account_id": "ABC12345.ap-south-1.aws", | ||
"username": "TST_USR", | ||
"password": "TST_PWD", | ||
}, | ||
"email_as_user_identifier": True, | ||
"email_domain": "example.com", | ||
source = SnowflakeQueriesSource.create( | ||
{ | ||
"connection": { | ||
"account_id": "ABC12345.ap-south-1.aws", | ||
"username": "TST_USR", | ||
"password": "TST_PWD", | ||
}, | ||
PipelineContext("run-id"), | ||
) | ||
assert ( | ||
source.identifiers.get_user_identifier("username", "[email protected]") | ||
== "[email protected]" | ||
) | ||
assert ( | ||
source.identifiers.get_user_identifier("username", None) | ||
== "[email protected]" | ||
) | ||
"email_as_user_identifier": True, | ||
"email_domain": "example.com", | ||
}, | ||
PipelineContext("run-id"), | ||
) | ||
assert ( | ||
source.identifiers.get_user_identifier("username", "[email protected]") | ||
== "[email protected]" | ||
) | ||
assert ( | ||
source.identifiers.get_user_identifier("username", None) | ||
== "[email protected]" | ||
) | ||
|
||
# We'd do best effort to form email, but would keep username as is, | ||
# if email can't be formed. | ||
source.identifiers.identifier_config.email_domain = None | ||
assert source.identifiers.get_user_identifier("username", None) == "username" | ||
|
||
|
||
@patch("snowflake.connector.connect") | ||
def test_user_identifiers_username_as_identifier(snowflake_connect, tmp_path): | ||
with patch("tempfile.tempdir", str(tmp_path)): | ||
source = SnowflakeQueriesSource.create( | ||
{ | ||
"connection": { | ||
"account_id": "ABC12345.ap-south-1.aws", | ||
"username": "TST_USR", | ||
"password": "TST_PWD", | ||
}, | ||
"email_as_user_identifier": False, | ||
source = SnowflakeQueriesSource.create( | ||
{ | ||
"connection": { | ||
"account_id": "ABC12345.ap-south-1.aws", | ||
"username": "TST_USR", | ||
"password": "TST_PWD", | ||
}, | ||
PipelineContext("run-id"), | ||
) | ||
assert ( | ||
source.identifiers.get_user_identifier("username", "[email protected]") | ||
== "username" | ||
) | ||
assert source.identifiers.get_user_identifier("username", None) == "username" | ||
"email_as_user_identifier": False, | ||
}, | ||
PipelineContext("run-id"), | ||
) | ||
assert ( | ||
source.identifiers.get_user_identifier("username", "[email protected]") | ||
== "username" | ||
) | ||
assert source.identifiers.get_user_identifier("username", None) == "username" |