-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 Add and update test to sap_rfc after change in credential passing l…
…ogic
- Loading branch information
adrian-wojcik
committed
Mar 18, 2024
1 parent
e5ee5b7
commit afab409
Showing
2 changed files
with
123 additions
and
7 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 |
---|---|---|
@@ -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