Skip to content

Commit 8847f27

Browse files
committed
total size in a node
1 parent 953dc6e commit 8847f27

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

services/storage/tests/unit/test_handlers_paths.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,16 @@ async def test_path_compute_size(
530530
total_num_files = sum(
531531
len(files_in_node) for files_in_node in list_of_files.values()
532532
)
533-
expected_project_total_size = project_params.allowed_file_sizes[0] * total_num_files
534533

534+
# get size of a full project
535+
expected_total_size = project_params.allowed_file_sizes[0] * total_num_files
536+
path = Path(project["uuid"])
535537
url = url_from_operation_id(
536538
client,
537539
initialized_app,
538540
"compute_path_total_size",
539541
location_id=f"{location_id}",
540-
path=project["uuid"],
542+
path=f"{path}",
541543
).with_query(user_id=user_id)
542544
response = await client.post(f"{url}")
543545

@@ -547,5 +549,32 @@ async def test_path_compute_size(
547549
PathTotalSizeCreate,
548550
)
549551
assert received
550-
assert received.path == Path(project["uuid"])
551-
assert received.size == expected_project_total_size
552+
assert received.path == path
553+
assert received.size == expected_total_size
554+
555+
# get size of a project/node
556+
selected_node_id = NodeID(random.choice(list(project["workbench"]))) # noqa: S311
557+
selected_node_s3_keys = [
558+
Path(s3_object_id) for s3_object_id in list_of_files[selected_node_id]
559+
]
560+
expected_total_size = project_params.allowed_file_sizes[0] * len(
561+
selected_node_s3_keys
562+
)
563+
path = Path(project["uuid"]) / f"{selected_node_id}"
564+
url = url_from_operation_id(
565+
client,
566+
initialized_app,
567+
"compute_path_total_size",
568+
location_id=f"{location_id}",
569+
path=f"{path}",
570+
).with_query(user_id=user_id)
571+
response = await client.post(f"{url}")
572+
573+
received, _ = assert_status(
574+
response,
575+
status.HTTP_200_OK,
576+
PathTotalSizeCreate,
577+
)
578+
assert received
579+
assert received.path == path
580+
assert received.size == expected_total_size

0 commit comments

Comments
 (0)