Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix bug related to logger.warning and tests in sap_rfc source #890

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading