Skip to content

Commit b58f26f

Browse files
fix: RPC tests
1 parent a0d89e4 commit b58f26f

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

services/storage/tests/unit/test_rpc_handlers_paths.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from models_library.api_schemas_storage import STORAGE_RPC_NAMESPACE
2424
from models_library.products import ProductName
2525
from models_library.projects_nodes_io import LocationID, NodeID, SimcoreS3FileID
26-
from models_library.rabbitmq_basic_types import RPCMethodName
2726
from models_library.users import UserID
2827
from pydantic import ByteSize, TypeAdapter
2928
from pytest_simcore.helpers.storage_utils import FileIDDict, ProjectWithFilesParams
@@ -69,7 +68,7 @@ async def _assert_compute_path_size(
6968
path: Path,
7069
expected_total_size: int,
7170
) -> ByteSize:
72-
async_job, async_job_name = await compute_path_size(
71+
async_job, _ = await compute_path_size(
7372
storage_rpc_client,
7473
product_name=product_name,
7574
user_id=user_id,
@@ -79,7 +78,7 @@ async def _assert_compute_path_size(
7978
async for job_composed_result in wait_and_get_result(
8079
storage_rpc_client,
8180
rpc_namespace=STORAGE_RPC_NAMESPACE,
82-
method_name=RPCMethodName(compute_path_size.__name__),
81+
method_name=compute_path_size.__name__,
8382
job_id=async_job.job_id,
8483
job_filter=AsyncJobFilter(
8584
user_id=user_id, product_name=product_name, client_name="PYTEST_CLIENT_NAME"
@@ -105,7 +104,7 @@ async def _assert_delete_paths(
105104
*,
106105
paths: set[Path],
107106
) -> None:
108-
async_job, async_job_name = await delete_paths(
107+
async_job, _ = await delete_paths(
109108
storage_rpc_client,
110109
product_name=product_name,
111110
user_id=user_id,
@@ -115,7 +114,7 @@ async def _assert_delete_paths(
115114
async for job_composed_result in wait_and_get_result(
116115
storage_rpc_client,
117116
rpc_namespace=STORAGE_RPC_NAMESPACE,
118-
method_name=RPCMethodName(compute_path_size.__name__),
117+
method_name=compute_path_size.__name__,
119118
job_id=async_job.job_id,
120119
job_filter=AsyncJobFilter(
121120
user_id=user_id, product_name=product_name, client_name="PYTEST_CLIENT_NAME"
@@ -155,6 +154,7 @@ async def test_path_compute_size(
155154
location_id: LocationID,
156155
with_random_project_with_files: tuple[
157156
dict[str, Any],
157+
dict[NodeID, dict[str, Any]],
158158
dict[NodeID, dict[SimcoreS3FileID, FileIDDict]],
159159
],
160160
project_params: ProjectWithFilesParams,
@@ -163,7 +163,7 @@ async def test_path_compute_size(
163163
assert (
164164
len(project_params.allowed_file_sizes) == 1
165165
), "test preconditions are not filled! allowed file sizes should have only 1 option for this test"
166-
project, list_of_files = with_random_project_with_files
166+
project, nodes, list_of_files = with_random_project_with_files
167167

168168
total_num_files = sum(
169169
len(files_in_node) for files_in_node in list_of_files.values()
@@ -182,7 +182,7 @@ async def test_path_compute_size(
182182
)
183183

184184
# get size of one of the nodes
185-
selected_node_id = NodeID(random.choice(list(project["workbench"]))) # noqa: S311
185+
selected_node_id = random.choice(list(nodes)) # noqa: S311
186186
path = Path(project["uuid"]) / f"{selected_node_id}"
187187
selected_node_s3_keys = [
188188
Path(s3_object_id) for s3_object_id in list_of_files[selected_node_id]
@@ -333,6 +333,7 @@ async def test_delete_paths(
333333
location_id: LocationID,
334334
with_random_project_with_files: tuple[
335335
dict[str, Any],
336+
dict[NodeID, dict[str, Any]],
336337
dict[NodeID, dict[SimcoreS3FileID, FileIDDict]],
337338
],
338339
project_params: ProjectWithFilesParams,
@@ -342,7 +343,7 @@ async def test_delete_paths(
342343
assert (
343344
len(project_params.allowed_file_sizes) == 1
344345
), "test preconditions are not filled! allowed file sizes should have only 1 option for this test"
345-
project, list_of_files = with_random_project_with_files
346+
project, nodes, list_of_files = with_random_project_with_files
346347

347348
total_num_files = sum(
348349
len(files_in_node) for files_in_node in list_of_files.values()
@@ -362,11 +363,7 @@ async def test_delete_paths(
362363

363364
# now select multiple random files to delete
364365
selected_paths = random.sample(
365-
list(
366-
list_of_files[
367-
NodeID(random.choice(list(project["workbench"]))) # noqa: S311
368-
]
369-
),
366+
list(list_of_files[random.choice(list(nodes))]), # noqa: S311
370367
round(project_params.workspace_files_count / 2),
371368
)
372369

@@ -375,7 +372,7 @@ async def test_delete_paths(
375372
location_id,
376373
user_id,
377374
product_name,
378-
paths=set({Path(_) for _ in selected_paths}),
375+
paths={Path(_) for _ in selected_paths},
379376
)
380377

381378
# the size is reduced by the amount of deleted files

0 commit comments

Comments
 (0)