@@ -1196,13 +1196,13 @@ async def test_copy_as_soft_link(
11961196 file , original_file_uuid = await upload_file (
11971197 TypeAdapter (ByteSize ).validate_python ("10Mib" ), faker .file_name ()
11981198 )
1199- url = (
1200- client . app . router [ "copy_as_soft_link" ]
1201- . url_for (
1202- file_id = urllib . parse . quote ( original_file_uuid , safe = "" ) ,
1203- )
1204- .with_query (user_id = user_id )
1205- )
1199+ url = url_from_operation_id (
1200+ client ,
1201+ initialized_app ,
1202+ "copy_as_soft_link" ,
1203+ file_id = urllib . parse . quote ( original_file_uuid , safe = "" ),
1204+ ) .with_query (user_id = user_id )
1205+
12061206 link_id = TypeAdapter (SimcoreS3FileID ).validate_python (
12071207 f"api/{ node_id } /{ faker .file_name ()} "
12081208 )
@@ -1216,28 +1216,29 @@ async def test_copy_as_soft_link(
12161216
12171217
12181218async def __list_files (
1219+ initialized_app : FastAPI ,
12191220 client : httpx .AsyncClient ,
12201221 user_id : UserID ,
12211222 location_id : LocationID ,
12221223 * ,
12231224 path : str ,
12241225 expand_dirs : bool ,
12251226) -> list [FileMetaDataGet ]:
1226- get_url = (
1227- client .app .router ["list_files_metadata" ]
1228- .url_for (
1229- location_id = f"{ location_id } " ,
1230- file_id = urllib .parse .quote (path , safe = "" ),
1231- )
1232- .with_query (user_id = user_id , expand_dirs = f"{ expand_dirs } " .lower ())
1233- )
1227+ get_url = url_from_operation_id (
1228+ client ,
1229+ initialized_app ,
1230+ "list_files_metadata" ,
1231+ location_id = f"{ location_id } " ,
1232+ file_id = urllib .parse .quote (path , safe = "" ),
1233+ ).with_query (user_id = user_id , expand_dirs = f"{ expand_dirs } " .lower ())
12341234 response = await client .get (f"{ get_url } " )
12351235 data , error = await assert_status (response , status .HTTP_200_OK )
12361236 assert not error
12371237 return TypeAdapter (list [FileMetaDataGet ]).validate_python (data )
12381238
12391239
12401240async def _list_files_legacy (
1241+ initialized_app : FastAPI ,
12411242 client : httpx .AsyncClient ,
12421243 user_id : UserID ,
12431244 location_id : LocationID ,
@@ -1246,11 +1247,17 @@ async def _list_files_legacy(
12461247 assert directory_file_upload .urls [0 ].path
12471248 directory_file_id = directory_file_upload .urls [0 ].path .strip ("/" )
12481249 return await __list_files (
1249- client , user_id , location_id , path = directory_file_id , expand_dirs = True
1250+ initialized_app ,
1251+ client ,
1252+ user_id ,
1253+ location_id ,
1254+ path = directory_file_id ,
1255+ expand_dirs = True ,
12501256 )
12511257
12521258
12531259async def _list_files_and_directories (
1260+ initialized_app : FastAPI ,
12541261 client : httpx .AsyncClient ,
12551262 user_id : UserID ,
12561263 location_id : LocationID ,
@@ -1260,7 +1267,12 @@ async def _list_files_and_directories(
12601267 directory_parent_path = Path (directory_file_upload .urls [0 ].path ).parent
12611268 directory_file_id = f"{ directory_parent_path } " .strip ("/" )
12621269 return await __list_files (
1263- client , user_id , location_id , path = directory_file_id , expand_dirs = False
1270+ initialized_app ,
1271+ client ,
1272+ user_id ,
1273+ location_id ,
1274+ path = directory_file_id ,
1275+ expand_dirs = False ,
12641276 )
12651277
12661278
@@ -1278,6 +1290,7 @@ async def test_is_directory_link_forces_link_type_and_size(
12781290 node_id : NodeID ,
12791291 create_simcore_file_id : Callable [[ProjectID , NodeID , str ], SimcoreS3FileID ],
12801292 create_upload_file_link_v2 : Callable [..., Awaitable [FileUploadSchema ]],
1293+ initialized_app : FastAPI ,
12811294 client : httpx .AsyncClient ,
12821295 location_id : LocationID ,
12831296 user_id : UserID ,
@@ -1296,7 +1309,7 @@ async def test_is_directory_link_forces_link_type_and_size(
12961309 assert len (directory_file_upload .urls ) == 1
12971310
12981311 files_and_directories : list [FileMetaDataGet ] = await _list_files_and_directories (
1299- client , user_id , location_id , directory_file_upload
1312+ initialized_app , client , user_id , location_id , directory_file_upload
13001313 )
13011314 assert len (files_and_directories ) == 1
13021315 assert files_and_directories [0 ].is_directory is True
@@ -1316,14 +1329,13 @@ async def test_ensure_expand_dirs_defaults_true(
13161329 autospec = True ,
13171330 )
13181331
1319- get_url = (
1320- client .app .router ["list_files_metadata" ]
1321- .url_for (
1322- location_id = f"{ location_id } " ,
1323- file_id = urllib .parse .quote ("mocked_path" , safe = "" ),
1324- )
1325- .with_query (user_id = user_id )
1326- )
1332+ get_url = url_from_operation_id (
1333+ client ,
1334+ initialized_app ,
1335+ "list_files_metadata" ,
1336+ location_id = f"{ location_id } " ,
1337+ file_id = urllib .parse .quote ("mocked_path" , safe = "" ),
1338+ ).with_query (user_id = user_id )
13271339 await client .get (f"{ get_url } " )
13281340
13291341 assert len (mocked_object .call_args_list ) == 1
@@ -1354,12 +1366,12 @@ async def test_upload_file_is_directory_and_remove_content(
13541366 )
13551367
13561368 files_and_directories : list [FileMetaDataGet ] = await _list_files_and_directories (
1357- client , user_id , location_id , directory_file_upload
1369+ initialized_app , client , user_id , location_id , directory_file_upload
13581370 )
13591371 assert len (files_and_directories ) == 1
13601372
13611373 list_of_files : list [FileMetaDataGet ] = await _list_files_legacy (
1362- client , user_id , location_id , directory_file_upload
1374+ initialized_app , client , user_id , location_id , directory_file_upload
13631375 )
13641376 assert len (list_of_files ) == 0
13651377
@@ -1373,54 +1385,52 @@ async def test_upload_file_is_directory_and_remove_content(
13731385 )
13741386
13751387 files_and_directories : list [FileMetaDataGet ] = await _list_files_and_directories (
1376- client , user_id , location_id , directory_file_upload
1388+ initialized_app , client , user_id , location_id , directory_file_upload
13771389 )
13781390 assert len (files_and_directories ) == 1
13791391
13801392 list_of_files : list [FileMetaDataGet ] = await _list_files_legacy (
1381- client , user_id , location_id , directory_file_upload
1393+ initialized_app , client , user_id , location_id , directory_file_upload
13821394 )
13831395 assert len (list_of_files ) == SUBDIR_COUNT * FILE_COUNT
13841396
13851397 # DELETE NOT EXISTING
13861398
1387- delete_url = (
1388- client .app .router ["delete_file" ]
1389- .url_for (
1390- location_id = f"{ location_id } " ,
1391- file_id = urllib .parse .quote (
1392- "/" .join (list_of_files [0 ].file_id .split ("/" )[:2 ]) + "/does_not_exist" ,
1393- safe = "" ,
1394- ),
1395- )
1396- .with_query (user_id = user_id )
1397- )
1399+ delete_url = url_from_operation_id (
1400+ client ,
1401+ initialized_app ,
1402+ "delete_file" ,
1403+ location_id = f"{ location_id } " ,
1404+ file_id = urllib .parse .quote (
1405+ "/" .join (list_of_files [0 ].file_id .split ("/" )[:2 ]) + "/does_not_exist" ,
1406+ safe = "" ,
1407+ ),
1408+ ).with_query (user_id = user_id )
13981409 response = await client .delete (f"{ delete_url } " )
13991410 _ , error = await assert_status (response , status .HTTP_204_NO_CONTENT )
14001411 assert error is None
14011412
14021413 list_of_files : list [FileMetaDataGet ] = await _list_files_legacy (
1403- client , user_id , location_id , directory_file_upload
1414+ initialized_app , client , user_id , location_id , directory_file_upload
14041415 )
14051416
14061417 assert len (list_of_files ) == SUBDIR_COUNT * FILE_COUNT
14071418
14081419 # DELETE ONE FILE FROM THE DIRECTORY
14091420
1410- delete_url = (
1411- client .app .router ["delete_file" ]
1412- .url_for (
1413- location_id = f"{ location_id } " ,
1414- file_id = urllib .parse .quote (list_of_files [0 ].file_id , safe = "" ),
1415- )
1416- .with_query (user_id = user_id )
1417- )
1421+ delete_url = url_from_operation_id (
1422+ client ,
1423+ initialized_app ,
1424+ "delete_file" ,
1425+ location_id = f"{ location_id } " ,
1426+ file_id = urllib .parse .quote (list_of_files [0 ].file_id , safe = "" ),
1427+ ).with_query (user_id = user_id )
14181428 response = await client .delete (f"{ delete_url } " )
14191429 _ , error = await assert_status (response , status .HTTP_204_NO_CONTENT )
14201430 assert error is None
14211431
14221432 list_of_files : list [FileMetaDataGet ] = await _list_files_legacy (
1423- client , user_id , location_id , directory_file_upload
1433+ initialized_app , client , user_id , location_id , directory_file_upload
14241434 )
14251435
14261436 assert len (list_of_files ) == SUBDIR_COUNT * FILE_COUNT - 1
@@ -1430,12 +1440,12 @@ async def test_upload_file_is_directory_and_remove_content(
14301440 await delete_directory (directory_file_upload = directory_file_upload )
14311441
14321442 list_of_files : list [FileMetaDataGet ] = await _list_files_legacy (
1433- client , user_id , location_id , directory_file_upload
1443+ initialized_app , client , user_id , location_id , directory_file_upload
14341444 )
14351445 assert len (list_of_files ) == 0
14361446
14371447 files_and_directories : list [FileMetaDataGet ] = await _list_files_and_directories (
1438- client , user_id , location_id , directory_file_upload
1448+ initialized_app , client , user_id , location_id , directory_file_upload
14391449 )
14401450 assert len (files_and_directories ) == 0
14411451
@@ -1445,6 +1455,7 @@ async def test_listing_more_than_1000_objects_in_bucket(
14451455 create_directory_with_files : Callable [
14461456 ..., AbstractAsyncContextManager [FileUploadSchema ]
14471457 ],
1458+ initialized_app : FastAPI ,
14481459 client : httpx .AsyncClient ,
14491460 location_id : LocationID ,
14501461 user_id : UserID ,
@@ -1457,7 +1468,7 @@ async def test_listing_more_than_1000_objects_in_bucket(
14571468 file_count = files_in_dir ,
14581469 ) as directory_file_upload :
14591470 list_of_files : list [FileMetaDataGet ] = await _list_files_legacy (
1460- client , user_id , location_id , directory_file_upload
1471+ initialized_app , client , user_id , location_id , directory_file_upload
14611472 )
14621473 # for now no more than 1000 objects will be returned
14631474 assert len (list_of_files ) == 1000
@@ -1504,11 +1515,9 @@ async def test_listing_with_project_id_filter(
15041515 "uuid_filter" : project_file_name if uuid_filter else None ,
15051516 }
15061517
1507- url = (
1508- client .app .router ["list_files_metadata" ]
1509- .url_for (location_id = f"{ location_id } " )
1510- .with_query (** {k : v for k , v in query .items () if v is not None })
1511- )
1518+ url = url_from_operation_id (
1519+ client , initialized_app , "list_files_metadata" , location_id = f"{ location_id } "
1520+ ).with_query (** {k : v for k , v in query .items () if v is not None })
15121521 response = await client .get (f"{ url } " )
15131522 data , _ = await assert_status (response , status .HTTP_200_OK )
15141523
0 commit comments