@@ -73,44 +73,36 @@ def setup_connections(self, create_mock_connections):
7373 )
7474 )
7575
76- @mock .patch (f"{ MODULE } .lib" , autospec = True )
77- def test_conn (self , mock_lib ):
78- from azure .datalake .store import core
79-
76+ @mock .patch (f"{ MODULE } .core.AzureDLFileSystem" , autospec = True )
77+ @mock .patch (f"{ MODULE } .ClientSecretCredential" , autospec = True )
78+ def test_conn_with_tenant_uses_client_secret_credential (self , mock_credential , mock_filesystem ):
8079 from airflow .providers .microsoft .azure .hooks .data_lake import AzureDataLakeHook
8180
8281 hook = AzureDataLakeHook (azure_data_lake_conn_id = "adl_test_key" )
83- assert hook ._conn is None
84- assert hook .conn_id == "adl_test_key"
85- assert isinstance (hook .get_conn (), core .AzureDLFileSystem )
86- assert mock_lib .auth .called
8782
88- @pytest .mark .usefixtures ("connection_without_tenant" )
89- @mock .patch (f"{ MODULE } .lib" )
90- @mock .patch (f"{ MODULE } .AzureIdentityCredentialAdapter" )
91- def test_fallback_to_azure_identity_credential_adppter_when_tenant_is_not_provided (
92- self ,
93- mock_azure_identity_credential_adapter ,
94- mock_datalake_store_lib ,
95- ):
96- from azure .datalake .store import core
83+ assert hook .get_conn () is mock_filesystem .return_value
84+ mock_credential .assert_called_once_with (
85+ tenant_id = "tenant" , client_id = "client_id" , client_secret = "client secret"
86+ )
87+ mock_filesystem .assert_called_once_with (mock_credential .return_value , store_name = "accountname" )
9788
89+ @pytest .mark .usefixtures ("connection_without_tenant" )
90+ @mock .patch (f"{ MODULE } .core.AzureDLFileSystem" , autospec = True )
91+ @mock .patch (f"{ MODULE } .get_sync_default_azure_credential" , autospec = True )
92+ def test_conn_without_tenant_uses_default_azure_credential (self , mock_credential , mock_filesystem ):
9893 from airflow .providers .microsoft .azure .hooks .data_lake import AzureDataLakeHook
9994
10095 hook = AzureDataLakeHook (azure_data_lake_conn_id = "adl_test_key_without_tenant" )
101- assert hook ._conn is None
102- assert hook .conn_id == "adl_test_key_without_tenant"
103- assert isinstance (hook .get_conn (), core .AzureDLFileSystem )
104- mock_azure_identity_credential_adapter .assert_called ()
105- args = mock_azure_identity_credential_adapter .call_args
106- assert args .kwargs ["managed_identity_client_id" ] is None
107- assert args .kwargs ["workload_identity_tenant_id" ] is None
108- mock_datalake_store_lib .auth .assert_not_called ()
96+
97+ assert hook .get_conn () is mock_filesystem .return_value
98+ mock_credential .assert_called_once_with (
99+ managed_identity_client_id = None , workload_identity_tenant_id = None
100+ )
101+ mock_filesystem .assert_called_once_with (mock_credential .return_value , store_name = "accountname" )
109102
110103 @pytest .mark .usefixtures ("connection" )
111104 @mock .patch (f"{ MODULE } .core.AzureDLFileSystem" , autospec = True )
112- @mock .patch (f"{ MODULE } .lib" , autospec = True )
113- def test_check_for_blob (self , mock_lib , mock_filesystem ):
105+ def test_check_for_blob (self , mock_filesystem ):
114106 from airflow .providers .microsoft .azure .hooks .data_lake import AzureDataLakeHook
115107
116108 mocked_glob = mock_filesystem .return_value .glob
@@ -120,8 +112,7 @@ def test_check_for_blob(self, mock_lib, mock_filesystem):
120112
121113 @pytest .mark .usefixtures ("connection" )
122114 @mock .patch (f"{ MODULE } .multithread.ADLUploader" , autospec = True )
123- @mock .patch (f"{ MODULE } .lib" , autospec = True )
124- def test_upload_file (self , mock_lib , mock_uploader ):
115+ def test_upload_file (self , mock_uploader ):
125116 from airflow .providers .microsoft .azure .hooks .data_lake import AzureDataLakeHook
126117
127118 hook = AzureDataLakeHook (azure_data_lake_conn_id = "adl_test_key" )
@@ -145,8 +136,7 @@ def test_upload_file(self, mock_lib, mock_uploader):
145136
146137 @pytest .mark .usefixtures ("connection" )
147138 @mock .patch (f"{ MODULE } .multithread.ADLDownloader" , autospec = True )
148- @mock .patch (f"{ MODULE } .lib" , autospec = True )
149- def test_download_file (self , mock_lib , mock_downloader ):
139+ def test_download_file (self , mock_downloader ):
150140 from airflow .providers .microsoft .azure .hooks .data_lake import AzureDataLakeHook
151141
152142 hook = AzureDataLakeHook (azure_data_lake_conn_id = "adl_test_key" )
@@ -170,8 +160,7 @@ def test_download_file(self, mock_lib, mock_downloader):
170160
171161 @pytest .mark .usefixtures ("connection" )
172162 @mock .patch (f"{ MODULE } .core.AzureDLFileSystem" , autospec = True )
173- @mock .patch (f"{ MODULE } .lib" , autospec = True )
174- def test_list_glob (self , mock_lib , mock_fs ):
163+ def test_list_glob (self , mock_fs ):
175164 from airflow .providers .microsoft .azure .hooks .data_lake import AzureDataLakeHook
176165
177166 hook = AzureDataLakeHook (azure_data_lake_conn_id = "adl_test_key" )
@@ -180,8 +169,7 @@ def test_list_glob(self, mock_lib, mock_fs):
180169
181170 @pytest .mark .usefixtures ("connection" )
182171 @mock .patch (f"{ MODULE } .core.AzureDLFileSystem" , autospec = True )
183- @mock .patch (f"{ MODULE } .lib" , autospec = True )
184- def test_list_walk (self , mock_lib , mock_fs ):
172+ def test_list_walk (self , mock_fs ):
185173 from airflow .providers .microsoft .azure .hooks .data_lake import AzureDataLakeHook
186174
187175 hook = AzureDataLakeHook (azure_data_lake_conn_id = "adl_test_key" )
@@ -190,8 +178,7 @@ def test_list_walk(self, mock_lib, mock_fs):
190178
191179 @pytest .mark .usefixtures ("connection" )
192180 @mock .patch (f"{ MODULE } .core.AzureDLFileSystem" , autospec = True )
193- @mock .patch (f"{ MODULE } .lib" , autospec = True )
194- def test_remove (self , mock_lib , mock_fs ):
181+ def test_remove (self , mock_fs ):
195182 from airflow .providers .microsoft .azure .hooks .data_lake import AzureDataLakeHook
196183
197184 hook = AzureDataLakeHook (azure_data_lake_conn_id = "adl_test_key" )
0 commit comments