From 1d5bcd78d7977fc2ddca00c701e619c70ea5ab27 Mon Sep 17 00:00:00 2001 From: LIU ZHE YOU Date: Mon, 13 Jul 2026 04:48:53 +0000 Subject: [PATCH] Fix Azure Data Factory async test on azure-mgmt-datafactory 10 The test patched the private module azure.mgmt.datafactory.models._models_py3, which the regenerated azure-mgmt-datafactory 10.0.0 removed, so mock.patch raised ModuleNotFoundError in the uncapped-dependency CI jobs on main. The mocked PipelineRun was only an opaque placeholder for the mocked pipeline_runs.get return value - the test asserts the exception is raised before the connection is ever used - so a neutral MagicMock removes the dependency on any specific SDK module layout. Follow-up to #69785, which fixed the collection-time break in the same file. --- .../tests/unit/microsoft/azure/hooks/test_data_factory.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_data_factory.py b/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_data_factory.py index 11a150c9234a8..92608f6101a94 100644 --- a/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_data_factory.py +++ b/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_data_factory.py @@ -679,19 +679,16 @@ async def test_get_adf_pipeline_run_status_cancelled(self, mock_get_pipeline_run assert response == mock_status @pytest.mark.asyncio - @mock.patch("azure.mgmt.datafactory.models._models_py3.PipelineRun") @mock.patch(f"{MODULE}.AzureDataFactoryAsyncHook.get_connection") @mock.patch(f"{MODULE}.AzureDataFactoryAsyncHook.get_async_conn") - async def test_get_pipeline_run_exception_without_resource( - self, mock_conn, mock_get_connection, mock_pipeline_run - ): + async def test_get_pipeline_run_exception_without_resource(self, mock_conn, mock_get_connection): """ Test get_pipeline_run function without passing the resource name to check the decorator function and raise exception """ mock_connection = Connection(extra={"factory_name": DATAFACTORY_NAME}) mock_get_connection.return_value = mock_connection - mock_conn.return_value.pipeline_runs.get.return_value = mock_pipeline_run + mock_conn.return_value.pipeline_runs.get.return_value = MagicMock() hook = AzureDataFactoryAsyncHook(AZURE_DATA_FACTORY_CONN_ID) with pytest.raises(AirflowException): await hook.get_pipeline_run(RUN_ID, None, DATAFACTORY_NAME)