forked from dyvenia/viadot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dyvenia#866 from adrian-wojcik/sap_rfc_local_confi…
…g_to_key_voult_change ♻️ Changed credentials logic in sap_rfc to get credentials from KeyVault
- Loading branch information
Showing
6 changed files
with
250 additions
and
43 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
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 |
---|---|---|
@@ -1,13 +1,52 @@ | ||
import pytest | ||
import logging | ||
|
||
from viadot.exceptions import CredentialError | ||
from viadot.config import local_config | ||
from viadot.tasks import SAPRFCToDF | ||
|
||
|
||
def test_sap_rfc_to_df_bbp(): | ||
sap_test_creds = local_config.get("SAP").get("QA") | ||
task = SAPRFCToDF( | ||
credentials=sap_test_creds, | ||
query="SELECT MATNR, MATKL, MTART, LAEDA FROM MARA WHERE LAEDA LIKE '2022%'", | ||
query="SELECT MATNR, MATKL, MTART, LAEDA FROM MARA WHERE LAEDA LIKE '20220110%'", | ||
func="BBP_RFC_READ_TABLE", | ||
) | ||
df = task.run() | ||
df = task.run(sap_credentials_key="SAP", env="QA") | ||
assert len(df.columns) == 4 and not df.empty | ||
|
||
|
||
def test_sap_rfc_to_df_wrong_sap_credential_key_bbp(caplog): | ||
task = SAPRFCToDF( | ||
query="SELECT MATNR, MATKL, MTART, LAEDA FROM MARA WHERE LAEDA LIKE '20220110%'", | ||
func="BBP_RFC_READ_TABLE", | ||
) | ||
with pytest.raises( | ||
CredentialError, | ||
match="Sap_credentials_key: SAP_test is not stored neither in KeyVault or Local Config!", | ||
): | ||
task.run( | ||
sap_credentials_key="SAP_test", | ||
) | ||
assert ( | ||
f"Getting credentials from Azure Key Vault was not possible. Either there is no key: SAP_test or env: DEV or there is not Key Vault in your environment." | ||
in caplog.text | ||
) | ||
|
||
|
||
def test_sap_rfc_to_df_wrong_env_bbp(caplog): | ||
task = SAPRFCToDF( | ||
query="SELECT MATNR, MATKL, MTART, LAEDA FROM MARA WHERE LAEDA LIKE '20220110%'", | ||
func="BBP_RFC_READ_TABLE", | ||
) | ||
with pytest.raises( | ||
CredentialError, | ||
match="Missing PROD_test credentials!", | ||
): | ||
task.run( | ||
sap_credentials_key="SAP", | ||
env="PROD_test", | ||
) | ||
assert ( | ||
f"Getting credentials from Azure Key Vault was not possible. Either there is no key: SAP or env: PROD_test or there is not Key Vault in your environment." | ||
in caplog.text | ||
) |
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
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
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
Oops, something went wrong.