Skip to content

Commit c19f1c2

Browse files
committed
bug: add size info
1 parent 475df4e commit c19f1c2

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/onc/modules/_OncDelivery.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ def _printProductOrderStats(self, fileList: list, runInfo: dict):
387387
print(f"Total download Time: {txtDownTime}")
388388

389389
# Print size and count of files
390-
print(f"{downloadCount} files ({humanize.naturalsize(size)}) downloaded")
390+
natural_size = humanize.naturalsize(size, binary=True)
391+
print(f"{downloadCount} files ({natural_size}) downloaded")
391392
else:
392393
print("No files downloaded.")
393394

src/onc/modules/_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def saveAsFile(
2424
raise FileExistsError(filePath)
2525

2626
start = time.time()
27-
size = 0
27+
size = len(response.content)
2828
with open(filePath, "wb") as file:
2929
file.write(response.content)
3030

tests/data_product_delivery/test_data_product_delivery_order.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def test_valid_no_metadata(requester, params, expected_keys_download_results, ut
4040
assert data["downloadResults"][0]["index"] == "1"
4141
assert data["downloadResults"][0]["downloaded"] is True
4242

43+
assert data["stats"]["totalSize"] != 0
44+
4345
assert util.get_download_files_num(requester) == 2, "The first two are png files."
4446

4547
util.assert_dict_key_types(

0 commit comments

Comments
 (0)