From 893319a30ff53e0af0072c55b31c0b0edc068b89 Mon Sep 17 00:00:00 2001 From: dirrao Date: Sat, 8 Jun 2024 10:35:06 +0530 Subject: [PATCH 1/2] Resolve azure provider deprecations in tests --- tests/deprecations_ignore.yml | 4 ---- .../microsoft/azure/hooks/test_adx.py | 20 +++++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/deprecations_ignore.yml b/tests/deprecations_ignore.yml index 57dbb7a6053ea..61deba1532795 100644 --- a/tests/deprecations_ignore.yml +++ b/tests/deprecations_ignore.yml @@ -314,9 +314,6 @@ - tests/providers/google/cloud/sensors/test_cloud_composer.py::TestCloudComposerEnvironmentSensor::test_cloud_composer_existence_sensor_async_execute_failure - tests/providers/google/cloud/sensors/test_gcs.py::TestTsFunction::test_should_support_cron - tests/providers/google/cloud/sensors/test_gcs.py::TestTsFunction::test_should_support_datetime -- tests/providers/google/cloud/transfers/test_azure_fileshare_to_gcs.py::TestAzureFileShareToGCSOperator::test_execute -- tests/providers/google/cloud/transfers/test_azure_fileshare_to_gcs.py::TestAzureFileShareToGCSOperator::test_execute_with_gzip -- tests/providers/google/cloud/transfers/test_azure_fileshare_to_gcs.py::TestAzureFileShareToGCSOperator::test_init - tests/providers/google/cloud/transfers/test_bigquery_to_postgres.py::TestBigQueryToPostgresOperator::test_execute_good_request_to_bq - tests/providers/google/cloud/transfers/test_gcs_to_gcs.py::TestGoogleCloudStorageToCloudStorageOperator::test_copy_files_into_a_folder - tests/providers/google/cloud/transfers/test_gcs_to_gcs.py::TestGoogleCloudStorageToCloudStorageOperator::test_execute_last_modified_time @@ -357,7 +354,6 @@ - tests/providers/google/marketing_platform/operators/test_analytics.py::TestGoogleAnalyticsRetrieveAdsLinksListOperator::test_execute - tests/providers/jdbc/operators/test_jdbc.py::TestJdbcOperator::test_execute_do_push - tests/providers/jdbc/operators/test_jdbc.py::TestJdbcOperator::test_execute_dont_push -- tests/providers/microsoft/azure/hooks/test_adx.py::TestAzureDataExplorerHook::test_backcompat_prefix_works - tests/providers/microsoft/mssql/operators/test_mssql.py::TestMsSqlOperator::test_get_hook_default - tests/providers/microsoft/mssql/operators/test_mssql.py::TestMsSqlOperator::test_get_hook_from_conn - tests/providers/microsoft/psrp/hooks/test_psrp.py::TestPsrpHook::test_invoke_cmdlet_deprecated_kwargs diff --git a/tests/providers/microsoft/azure/hooks/test_adx.py b/tests/providers/microsoft/azure/hooks/test_adx.py index 55936bce8f602..458a8c9c580db 100644 --- a/tests/providers/microsoft/azure/hooks/test_adx.py +++ b/tests/providers/microsoft/azure/hooks/test_adx.py @@ -23,7 +23,7 @@ from azure.kusto.data import ClientRequestProperties, KustoClient from packaging.version import Version -from airflow.exceptions import AirflowException +from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning from airflow.models import Connection from airflow.providers.microsoft.azure.hooks.adx import AzureDataExplorerHook @@ -279,20 +279,28 @@ def test_run_query(self, mock_execute, mocked_connection): assert args[1]["properties"]._options["option1"] == "option_value" @pytest.mark.parametrize( - "mocked_connection", + "mocked_connection, warning", [ pytest.param( "a://usr:pw@host?extra__azure_data_explorer__tenant=my-tenant" "&extra__azure_data_explorer__auth_method=AAD_APP", + True, id="prefix", ), - pytest.param("a://usr:pw@host?tenant=my-tenant&auth_method=AAD_APP", id="no-prefix"), + pytest.param("a://usr:pw@host?tenant=my-tenant&auth_method=AAD_APP", False, id="no-prefix"), ], - indirect=True, + indirect=["mocked_connection"], ) - def test_backcompat_prefix_works(self, mocked_connection): + def test_backcompat_prefix_works(self, mocked_connection, warning): hook = AzureDataExplorerHook(azure_data_explorer_conn_id=mocked_connection.conn_id) - assert hook.connection._kcsb.data_source == "host" + if warning: + with pytest.warns( + AirflowProviderDeprecationWarning, + match="`extra__azure_data_explorer__.*` is deprecated in azure connection extra, please use `.*` instead", + ): + assert hook.connection._kcsb.data_source == "host" + else: + assert hook.connection._kcsb.data_source == "host" assert hook.connection._kcsb.application_client_id == "usr" assert hook.connection._kcsb.application_key == "pw" assert hook.connection._kcsb.authority_id == "my-tenant" From 2014389f298566502ac9546c30e27330c2de62b5 Mon Sep 17 00:00:00 2001 From: dirrao Date: Sat, 22 Jun 2024 18:04:00 +0530 Subject: [PATCH 2/2] Resolve azure provider deprecations in tests --- .../microsoft/azure/hooks/test_adx.py | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/tests/providers/microsoft/azure/hooks/test_adx.py b/tests/providers/microsoft/azure/hooks/test_adx.py index 458a8c9c580db..e2001c93848d3 100644 --- a/tests/providers/microsoft/azure/hooks/test_adx.py +++ b/tests/providers/microsoft/azure/hooks/test_adx.py @@ -23,7 +23,7 @@ from azure.kusto.data import ClientRequestProperties, KustoClient from packaging.version import Version -from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning +from airflow.exceptions import AirflowException from airflow.models import Connection from airflow.providers.microsoft.azure.hooks.adx import AzureDataExplorerHook @@ -279,28 +279,15 @@ def test_run_query(self, mock_execute, mocked_connection): assert args[1]["properties"]._options["option1"] == "option_value" @pytest.mark.parametrize( - "mocked_connection, warning", + "mocked_connection", [ - pytest.param( - "a://usr:pw@host?extra__azure_data_explorer__tenant=my-tenant" - "&extra__azure_data_explorer__auth_method=AAD_APP", - True, - id="prefix", - ), - pytest.param("a://usr:pw@host?tenant=my-tenant&auth_method=AAD_APP", False, id="no-prefix"), + pytest.param("a://usr:pw@host?tenant=my-tenant&auth_method=AAD_APP", id="no-prefix"), ], indirect=["mocked_connection"], ) - def test_backcompat_prefix_works(self, mocked_connection, warning): + def test_prefix_works(self, mocked_connection): hook = AzureDataExplorerHook(azure_data_explorer_conn_id=mocked_connection.conn_id) - if warning: - with pytest.warns( - AirflowProviderDeprecationWarning, - match="`extra__azure_data_explorer__.*` is deprecated in azure connection extra, please use `.*` instead", - ): - assert hook.connection._kcsb.data_source == "host" - else: - assert hook.connection._kcsb.data_source == "host" + assert hook.connection._kcsb.data_source == "host" assert hook.connection._kcsb.application_client_id == "usr" assert hook.connection._kcsb.application_key == "pw" assert hook.connection._kcsb.authority_id == "my-tenant" @@ -315,7 +302,7 @@ def test_backcompat_prefix_works(self, mocked_connection, warning): ], indirect=True, ) - def test_backcompat_prefix_both_causes_warning(self, mocked_connection): + def test_prefix_both_causes_warning(self, mocked_connection): hook = AzureDataExplorerHook(azure_data_explorer_conn_id=mocked_connection.conn_id) assert hook.connection._kcsb.data_source == "host" assert hook.connection._kcsb.application_client_id == "usr"