@@ -1073,21 +1073,22 @@ async def test_download_file_the_file_is_missing_from_the_directory(
10731073 missing_s3_file_id = TypeAdapter (SimcoreS3FileID ).validate_python (
10741074 f"{ dir_path_in_s3 } /missing_inside_dir.file"
10751075 )
1076- download_url = (
1077- client . app . router [ "download_file" ]
1078- . url_for (
1079- location_id = f" { location_id } " ,
1080- file_id = urllib . parse . quote ( missing_s3_file_id , safe = "" ) ,
1081- )
1082- .with_query (user_id = user_id )
1083- )
1076+ download_url = url_from_operation_id (
1077+ client ,
1078+ initialized_app ,
1079+ "download_file " ,
1080+ location_id = f" { location_id } " ,
1081+ file_id = urllib . parse . quote ( missing_s3_file_id , safe = "" ),
1082+ ) .with_query (user_id = user_id )
1083+
10841084 response = await client .get (f"{ download_url } " )
1085- data , error = await assert_status (response , status .HTTP_404_NOT_FOUND )
1085+ data , error = assert_status (response , status .HTTP_404_NOT_FOUND , None )
10861086 assert data is None
10871087 assert missing_s3_file_id in error ["message" ]
10881088
10891089
10901090async def test_download_file_access_rights (
1091+ initialized_app : FastAPI ,
10911092 client : httpx .AsyncClient ,
10921093 location_id : int ,
10931094 user_id : UserID ,
@@ -1105,17 +1106,16 @@ async def test_download_file_access_rights(
11051106 )
11061107 is False
11071108 )
1109+ download_url = url_from_operation_id (
1110+ client ,
1111+ initialized_app ,
1112+ "download_file" ,
1113+ location_id = f"{ location_id } " ,
1114+ file_id = urllib .parse .quote (missing_file , safe = "" ),
1115+ ).with_query (user_id = user_id )
11081116
1109- download_url = (
1110- client .app .router ["download_file" ]
1111- .url_for (
1112- location_id = f"{ location_id } " ,
1113- file_id = urllib .parse .quote (missing_file , safe = "" ),
1114- )
1115- .with_query (user_id = user_id )
1116- )
11171117 response = await client .get (f"{ download_url } " )
1118- data , error = await assert_status (response , status .HTTP_403_FORBIDDEN )
1118+ data , error = assert_status (response , status .HTTP_403_FORBIDDEN , None )
11191119 assert data is None
11201120 assert "Insufficient access rights" in error ["message" ]
11211121
@@ -1131,6 +1131,7 @@ async def test_delete_file(
11311131 sqlalchemy_async_engine : AsyncEngine ,
11321132 storage_s3_client : SimcoreS3API ,
11331133 storage_s3_bucket : S3BucketName ,
1134+ initialized_app : FastAPI ,
11341135 client : httpx .AsyncClient ,
11351136 file_size : ByteSize ,
11361137 upload_file : Callable [[ByteSize , str ], Awaitable [tuple [Path , SimcoreS3FileID ]]],
@@ -1140,16 +1141,15 @@ async def test_delete_file(
11401141):
11411142 _ , uploaded_file_uuid = await upload_file (file_size , faker .file_name ())
11421143
1143- delete_url = (
1144- client .app .router ["delete_file" ]
1145- .url_for (
1146- location_id = f"{ location_id } " ,
1147- file_id = urllib .parse .quote (uploaded_file_uuid , safe = "" ),
1148- )
1149- .with_query (user_id = user_id )
1150- )
1144+ delete_url = url_from_operation_id (
1145+ client ,
1146+ initialized_app ,
1147+ "delete_file" ,
1148+ location_id = f"{ location_id } " ,
1149+ file_id = urllib .parse .quote (uploaded_file_uuid , safe = "" ),
1150+ ).with_query (user_id = user_id )
11511151 response = await client .delete (f"{ delete_url } " )
1152- await assert_status (response , status .HTTP_204_NO_CONTENT )
1152+ assert_status (response , status .HTTP_204_NO_CONTENT , None )
11531153
11541154 # check the entry in db is removed
11551155 await assert_file_meta_data_in_db (
@@ -1181,13 +1181,12 @@ async def test_copy_as_soft_link(
11811181 # missing simcore_file_id returns 404
11821182 missing_file_uuid = create_simcore_file_id (project_id , node_id , faker .file_name ())
11831183 invalid_link_id = create_simcore_file_id (uuid4 (), uuid4 (), faker .file_name ())
1184- url = (
1185- client .app .router ["copy_as_soft_link" ]
1186- .url_for (
1187- file_id = urllib .parse .quote (missing_file_uuid , safe = "" ),
1188- )
1189- .with_query (user_id = user_id )
1190- )
1184+ url = url_from_operation_id (
1185+ client ,
1186+ initialized_app ,
1187+ "copy_as_soft_link" ,
1188+ file_id = urllib .parse .quote (missing_file_uuid , safe = "" ),
1189+ ).with_query (user_id = user_id )
11911190 response = await client .post (
11921191 f"{ url } " , json = jsonable_encoder (SoftCopyBody (link_id = invalid_link_id ))
11931192 )
0 commit comments