Skip to content

Commit

Permalink
Merge pull request #890 from adrian-wojcik/sap_rfc_local_config_to_ke…
Browse files Browse the repository at this point in the history
…y_voult_change

🐛 Fix bug related to logger.warning and tests in sap_rfc source
  • Loading branch information
Rafalz13 committed Apr 10, 2024
2 parents bb4c4d5 + c445782 commit b2d8a76
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tests/integration/tasks/test_sap_rfc_to_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_sap_rfc_to_df_wrong_sap_credential_key_bbp(caplog):
)
with pytest.raises(
CredentialError,
match="Sap_credentials_key: SAP_test is not stored neither in KeyVault or Local Config!",
match="sap_credentials_key: SAP_test is not stored neither in KeyVault or local config!",
):
task.run(
sap_credentials_key="SAP_test",
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/test_sap_rfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ def test___build_pandas_filter_query_v2():
def test_default_credentials_warning_SAPRFC(caplog):
_ = SAPRFC()
assert (
f"Your credentials will use DEV environment from local config. If you would like to use different one - please specified it in sap_credentials parameter"
f"Your credentials will use DEV environment from local config. If you would like to use different one - please specified it in env parameter"
in caplog.text
)


def test_default_credentials_warning_SAPRFCV2(caplog):
_ = SAPRFCV2()
assert (
f"Your credentials will use DEV environment from local config. If you would like to use different one - please specified it in sap_credentials parameter"
f"Your credentials will use DEV environment from local config. If you would like to use different one - please specified it in env parameter"
in caplog.text
)

Expand All @@ -222,7 +222,7 @@ def test_credentials_dictionary_wrong_key_warning_SAPRFC(caplog):
in caplog.text
)
assert (
f"Your credentials will use DEV environment from local config. If you would like to use different one - please specified it in sap_credentials parameter"
f"Your credentials will use DEV environment from local config. If you would like to use different one - please specified it in env parameter"
in caplog.text
)

Expand All @@ -241,15 +241,15 @@ def test_credentials_dictionary_wrong_key_warning_SAPRFCV2(caplog):
in caplog.text
)
assert (
f"Your credentials will use DEV environment from local config. If you would like to use different one - please specified it in sap_credentials parameter"
f"Your credentials will use DEV environment from local config. If you would like to use different one - please specified it in env parameter"
in caplog.text
)


def test_sap_credentials_key_wrong_value_error_SAPRFC(caplog):
with pytest.raises(
CredentialError,
match="Sap_credentials_key: SAP_test is not stored neither in KeyVault or Local Config!",
match="sap_credentials_key: SAP_test is not stored neither in KeyVault or local config!",
):
with caplog.at_level(logging.ERROR):
_ = SAPRFC(sap_credentials_key="SAP_test")
Expand All @@ -258,7 +258,7 @@ def test_sap_credentials_key_wrong_value_error_SAPRFC(caplog):
def test_sap_credentials_key_wrong_value_error_SAPRFCV2(caplog):
with pytest.raises(
CredentialError,
match="Sap_credentials_key: SAP_test is not stored neither in KeyVault or Local Config!",
match="sap_credentials_key: SAP_test is not stored neither in KeyVault or local config!",
):
with caplog.at_level(logging.ERROR):
_ = SAPRFC(sap_credentials_key="SAP_test")
Expand Down
8 changes: 4 additions & 4 deletions viadot/sources/sap_rfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ def __init__(

if sap_credentials is None:
logger.warning(
f"Your credentials will use {env} environment from local config. If you would like to use different one - please specified it in sap_credentials parameter."
f"Your credentials will use {env} environment from local config. If you would like to use different one - please specified it in env parameter."
)
try:
sap_credentials = local_config.get(sap_credentials_key).get(env)
except AttributeError:
raise CredentialError(
f"sap_credentials_key: {sap_credentials_key} is not stored neither in KeyVault or Local Config!"
f"sap_credentials_key: {sap_credentials_key} is not stored neither in KeyVault or local config!"
)
if sap_credentials is None:
raise CredentialError(f"Missing {env} credentials!")
Expand Down Expand Up @@ -747,13 +747,13 @@ def __init__(

if sap_credentials is None:
logger.warning(
f"Your credentials will use {env} environment from local config. If you would like to use different one - please specified it in sap_credentials parameter."
f"Your credentials will use {env} environment from local config. If you would like to use different one - please specified it in env parameter."
)
try:
sap_credentials = local_config.get(sap_credentials_key).get(env)
except AttributeError:
raise CredentialError(
f"sap_credentials_key: {sap_credentials_key} is not stored neither in KeyVault or Local Config!"
f"sap_credentials_key: {sap_credentials_key} is not stored neither in KeyVault or local config!"
)
if sap_credentials is None:
raise CredentialError(f"Missing {env} credentials!")
Expand Down

0 comments on commit b2d8a76

Please sign in to comment.