Skip to content

Commit

Permalink
remove unnecessary patching, test for missing email_domain
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurinehate committed Dec 26, 2024
1 parent 97a2cea commit afaa90b
Showing 1 changed file with 39 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit afaa90b

Please sign in to comment.