diff --git a/src/viadot/orchestration/prefect/flows/__init__.py b/src/viadot/orchestration/prefect/flows/__init__.py index a3cdb9f5e..c6419e8a1 100644 --- a/src/viadot/orchestration/prefect/flows/__init__.py +++ b/src/viadot/orchestration/prefect/flows/__init__.py @@ -25,6 +25,7 @@ from .transform import transform from .transform_and_catalog import transform_and_catalog + __all__ = [ "cloud_for_customers_to_adls", "cloud_for_customers_to_databricks", diff --git a/src/viadot/orchestration/prefect/flows/salesforce_to_adls.py b/src/viadot/orchestration/prefect/flows/salesforce_to_adls.py index 4b6213851..cf45505a4 100644 --- a/src/viadot/orchestration/prefect/flows/salesforce_to_adls.py +++ b/src/viadot/orchestration/prefect/flows/salesforce_to_adls.py @@ -14,7 +14,7 @@ retry_delay_seconds=60, task_runner=ConcurrentTaskRunner, ) -def salesforce_to_adls( +def salesforce_to_adls( # noqa: PLR0913 config_key: str | None = None, azure_key_vault_secret: str | None = None, env: str | None = None, diff --git a/src/viadot/orchestration/prefect/tasks/__init__.py b/src/viadot/orchestration/prefect/tasks/__init__.py index 173fd50e1..cd8ace127 100644 --- a/src/viadot/orchestration/prefect/tasks/__init__.py +++ b/src/viadot/orchestration/prefect/tasks/__init__.py @@ -22,6 +22,7 @@ from .sharepoint import sharepoint_download_file, sharepoint_to_df from .sql_server import create_sql_server_table, sql_server_query, sql_server_to_df + __all__ = [ "adls_upload", "df_to_adls", diff --git a/src/viadot/sources/__init__.py b/src/viadot/sources/__init__.py index c0c706a2f..89ba0b85e 100644 --- a/src/viadot/sources/__init__.py +++ b/src/viadot/sources/__init__.py @@ -16,6 +16,7 @@ from .sql_server import SQLServer from .uk_carbon_intensity import UKCarbonIntensity + __all__ = [ "CloudForCustomers", "Epicor", diff --git a/src/viadot/sources/salesforce.py b/src/viadot/sources/salesforce.py index 3f0d98710..c5c0034c1 100644 --- a/src/viadot/sources/salesforce.py +++ b/src/viadot/sources/salesforce.py @@ -115,7 +115,7 @@ def api_connection( """ if not query: columns_str = ", ".join(columns) if columns else "FIELDS(STANDARD)" - query = f"SELECT {columns_str} FROM {table}" + query = f"SELECT {columns_str} FROM {table}" # noqa: S608 self.data = self.salesforce.query(query).get("records") diff --git a/tests/integration/orchestration/prefect/flows/test_salesforce.py b/tests/integration/orchestration/prefect/flows/test_salesforce.py index cf28048ff..2eb44a822 100644 --- a/tests/integration/orchestration/prefect/flows/test_salesforce.py +++ b/tests/integration/orchestration/prefect/flows/test_salesforce.py @@ -3,7 +3,9 @@ from viadot.orchestration.prefect.flows import salesforce_to_adls -def test_salesforce_to_adls(azure_key_vault_secret, adls_path, adls_azure_key_vault_secret): +def test_salesforce_to_adls( + azure_key_vault_secret, adls_path, adls_azure_key_vault_secret +): """Test Salesforce prefect flow.""" state = salesforce_to_adls( azure_key_vault_secret=azure_key_vault_secret, diff --git a/tests/unit/test_salesforce.py b/tests/unit/test_salesforce.py index 957e78adf..0a70145b2 100644 --- a/tests/unit/test_salesforce.py +++ b/tests/unit/test_salesforce.py @@ -7,10 +7,11 @@ from viadot.sources import Salesforce from viadot.sources.salesforce import SalesforceCredentials + variables = { "credentials": { "username": "test_user", - "password": "test_password", + "password": "test_password", # pragma: allowlist secret "token": "test_token", }, "records_1": [ @@ -40,11 +41,13 @@ } -@pytest.mark.basic() +@pytest.mark.basic def test_salesforce_init_dev_env(mocker): """Test Salesforce, starting in dev mode.""" mock_sf_instance = mocker.MagicMock(spec=SimpleSalesforce) - mocker.patch("viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance) + mocker.patch( + "viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance + ) sf_instance = Salesforce(credentials=variables["credentials"], env="DEV") assert sf_instance.salesforce == mock_sf_instance @@ -53,27 +56,29 @@ def test_salesforce_init_dev_env(mocker): class TestSalesforceCredentials: """Test Salesforce Credentials Class.""" - @pytest.mark.basic() + @pytest.mark.basic def test_salesforce_credentials(self): """Test Salesforce credentials.""" SalesforceCredentials( username="test_user", - password="test_password", - token="test_token", + password="test_password", # noqa: S106 # pragma: allowlist secret + token="test_token", # noqa: S106 ) -@pytest.mark.basic() +@pytest.mark.basic def test_salesforce_init_prod_env(mocker): """Test Salesforce, starting in prod mode.""" mock_sf_instance = mocker.MagicMock(spec=SimpleSalesforce) - mocker.patch("viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance) + mocker.patch( + "viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance + ) sf_instance = Salesforce(credentials=variables["credentials"], env="PROD") assert sf_instance.salesforce == mock_sf_instance -@pytest.mark.basic() +@pytest.mark.basic def test_salesforce_invalid_env(): """Test Salesforce, invalid `env` parameter.""" with pytest.raises( @@ -82,19 +87,24 @@ def test_salesforce_invalid_env(): Salesforce(credentials=variables["credentials"], env="INVALID") -@pytest.mark.basic() +@pytest.mark.basic def test_salesforce_missing_credentials(): """Test Salesforce missing credentials.""" - incomplete_creds = {"username": "user", "password": "pass"} + incomplete_creds = { + "username": "user", # pragma: allowlist secret + "password": "pass", # pragma: allowlist secret + } with pytest.raises(CredentialError): Salesforce(credentials=incomplete_creds) -@pytest.mark.connect() +@pytest.mark.connect def test_salesforce_api_connection(mocker): """Test Salesforce `api_connection` method with a query.""" mock_sf_instance = mocker.MagicMock(spec=SimpleSalesforce) - mocker.patch("viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance) + mocker.patch( + "viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance + ) salesforce_instance = Salesforce(credentials=variables["credentials"]) mock_sf_instance.query.return_value = {"records": variables["records_1"]} @@ -105,11 +115,13 @@ def test_salesforce_api_connection(mocker): mock_sf_instance.query.assert_called_once_with("SELECT Id, Name FROM Account") -@pytest.mark.connect() +@pytest.mark.connect def test_salesforce_api_connection_with_columns(mocker): """Test Salesforce `api_connection` method with columns.""" mock_sf_instance = mocker.MagicMock(spec=SimpleSalesforce) - mocker.patch("viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance) + mocker.patch( + "viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance + ) salesforce_instance = Salesforce(credentials=variables["credentials"]) mock_sf_instance.query.return_value = {"records": variables["records_2"]} @@ -120,11 +132,13 @@ def test_salesforce_api_connection_with_columns(mocker): mock_sf_instance.query.assert_called_once_with("SELECT Id, Name FROM Account") -@pytest.mark.functions() +@pytest.mark.functions def test_salesforce_to_df(mocker): """Test Salesforce `to_df` method.""" mock_sf_instance = mocker.MagicMock(spec=SimpleSalesforce) - mocker.patch("viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance) + mocker.patch( + "viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance + ) salesforce_instance = Salesforce(credentials=variables["credentials"]) salesforce_instance.data = variables["data"] @@ -141,11 +155,13 @@ def test_salesforce_to_df(mocker): assert df.iloc[0]["Id"] == "001" -@pytest.mark.functions() +@pytest.mark.functions def test_salesforce_to_df_empty_data(mocker): """Test Salesforce `to_df` method with empty df.""" mock_sf_instance = mocker.MagicMock(spec=SimpleSalesforce) - mocker.patch("viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance) + mocker.patch( + "viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance + ) salesforce_instance = Salesforce(credentials=variables["credentials"]) salesforce_instance.data = [] @@ -153,11 +169,13 @@ def test_salesforce_to_df_empty_data(mocker): salesforce_instance.to_df(if_empty="fail") -@pytest.mark.functions() +@pytest.mark.functions def test_salesforce_to_df_warn_empty_data(mocker): """Test Salesforce `to_df` method with empty df, warn.""" mock_sf_instance = mocker.MagicMock(spec=SimpleSalesforce) - mocker.patch("viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance) + mocker.patch( + "viadot.sources.salesforce.SimpleSalesforce", return_value=mock_sf_instance + ) salesforce_instance = Salesforce(credentials=variables["credentials"]) salesforce_instance.data = []