@@ -53,9 +53,7 @@ def google_drive_empty_folder(google_drive_connection_config):
5353 from googleapiclient .discovery import build
5454
5555 access_config = google_drive_connection_config .access_config .get_secret_value ()
56- creds = service_account .Credentials .from_service_account_info (
57- access_config .service_account_key
58- )
56+ creds = service_account .Credentials .from_service_account_info (access_config .service_account_key )
5957 service = build ("drive" , "v3" , credentials = creds )
6058
6159 # Create an empty folder.
@@ -120,23 +118,16 @@ def test_google_drive_precheck_invalid_parameter(google_drive_connection_config)
120118 access_config = google_drive_connection_config .access_config ,
121119 )
122120 index_config = GoogleDriveIndexerConfig (recursive = True )
123- indexer = GoogleDriveIndexer (
124- connection_config = connection_config , index_config = index_config
125- )
121+ indexer = GoogleDriveIndexer (connection_config = connection_config , index_config = index_config )
126122 with pytest .raises (SourceConnectionError ) as excinfo :
127123 indexer .precheck ()
128- assert (
129- "invalid" in str (excinfo .value ).lower ()
130- or "not found" in str (excinfo .value ).lower ()
131- )
124+ assert "invalid" in str (excinfo .value ).lower () or "not found" in str (excinfo .value ).lower ()
132125
133126
134127# Precheck fails due to lack of permission (simulate via monkeypatching).
135128@pytest .mark .tags ("google-drive" , "precheck" )
136129@requires_env ("GOOGLE_DRIVE_ID" , "GOOGLE_DRIVE_SERVICE_KEY" )
137- def test_google_drive_precheck_no_permission (
138- google_drive_connection_config , monkeypatch
139- ):
130+ def test_google_drive_precheck_no_permission (google_drive_connection_config , monkeypatch ):
140131 index_config = GoogleDriveIndexerConfig (recursive = True )
141132 indexer = GoogleDriveIndexer (
142133 connection_config = google_drive_connection_config ,
@@ -153,10 +144,7 @@ def fake_get_root_info(files_client, object_id):
153144 monkeypatch .setattr (indexer , "get_root_info" , fake_get_root_info )
154145 with pytest .raises (SourceConnectionError ) as excinfo :
155146 indexer .precheck ()
156- assert (
157- "forbidden" in str (excinfo .value ).lower ()
158- or "permission" in str (excinfo .value ).lower ()
159- )
147+ assert "forbidden" in str (excinfo .value ).lower () or "permission" in str (excinfo .value ).lower ()
160148
161149
162150# Precheck fails when the folder is empty.
@@ -206,15 +194,10 @@ def test_google_drive_precheck_invalid_drive_id(google_drive_connection_config):
206194 access_config = google_drive_connection_config .access_config ,
207195 )
208196 index_config = GoogleDriveIndexerConfig (recursive = True )
209- indexer = GoogleDriveIndexer (
210- connection_config = connection_config , index_config = index_config
211- )
197+ indexer = GoogleDriveIndexer (connection_config = connection_config , index_config = index_config )
212198 with pytest .raises (SourceConnectionError ) as excinfo :
213199 indexer .precheck ()
214- assert (
215- "invalid" in str (excinfo .value ).lower ()
216- or "not found" in str (excinfo .value ).lower ()
217- )
200+ assert "invalid" in str (excinfo .value ).lower () or "not found" in str (excinfo .value ).lower ()
218201
219202
220203MIME_TYPES_TO_TEST = [
@@ -244,19 +227,15 @@ async def test_google_drive_export_by_type(expected_mime, temp_dir):
244227 index_config = GoogleDriveIndexerConfig (recursive = True )
245228 download_config = GoogleDriveDownloaderConfig (download_dir = temp_dir )
246229
247- indexer = GoogleDriveIndexer (
248- connection_config = connection_config , index_config = index_config
249- )
230+ indexer = GoogleDriveIndexer (connection_config = connection_config , index_config = index_config )
250231 downloader = GoogleDriveDownloader (
251232 connection_config = connection_config , download_config = download_config
252233 )
253234
254235 file_datas = list (indexer .run ())
255236
256237 # Filter only the target MIME type
257- target_files = [
258- f for f in file_datas if f .additional_metadata .get ("mimeType" ) == expected_mime
259- ]
238+ target_files = [f for f in file_datas if f .additional_metadata .get ("mimeType" ) == expected_mime ]
260239 assert target_files , f"No files found with MIME type: { expected_mime } "
261240
262241 for file_data in target_files :
0 commit comments