From 663de0631e6b20974a6a550c99ec82bdc03274ac Mon Sep 17 00:00:00 2001 From: nucleogenic Date: Thu, 22 Sep 2022 21:41:12 +0100 Subject: [PATCH] Added tests for extracting .sit and .7z archive formats --- python/web/tests/api/test_json_api.py | 21 +++++++++++------- python/web/tests/assets/test_image.7z | Bin 0 -> 379 bytes python/web/tests/assets/test_image.sit | Bin 0 -> 536 bytes .../{test_image.hds.zip => test_image.zip} | Bin 1239 -> 1257 bytes 4 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 python/web/tests/assets/test_image.7z create mode 100644 python/web/tests/assets/test_image.sit rename python/web/tests/assets/{test_image.hds.zip => test_image.zip} (76%) diff --git a/python/web/tests/api/test_json_api.py b/python/web/tests/api/test_json_api.py index eb7d958e..20ee404b 100644 --- a/python/web/tests/api/test_json_api.py +++ b/python/web/tests/api/test_json_api.py @@ -443,14 +443,19 @@ def test_delete_file(http_client, create_test_image, list_files): # route("/files/extract_image", methods=["POST"]) -# TODO: Add test files for all supported formats -def test_extract_file(httpserver, http_client, list_files, delete_file): - image_file_name = "test_image.hds" - zip_file_name = "test_image.hds.zip" - http_path = f"/images/{zip_file_name}" +@pytest.mark.parametrize( + "archive_file_name,image_file_name", + [ + ("test_image.zip", "test_image_from_zip.hds"), + ("test_image.sit", "test_image_from_sit.hds"), + ("test_image.7z", "test_image_from_7z.hds"), + ], +) +def test_extract_file(httpserver, http_client, list_files, delete_file, archive_file_name, image_file_name): + http_path = f"/images/{archive_file_name}" url = httpserver.url_for(http_path) - with open(f"tests/assets/{zip_file_name}", mode="rb") as file: + with open(f"tests/assets/{archive_file_name}", mode="rb") as file: zip_file_data = file.read() httpserver.expect_request(http_path).respond_with_data( @@ -468,7 +473,7 @@ def test_extract_file(httpserver, http_client, list_files, delete_file): response = http_client.post( "/files/extract_image", data={ - "archive_file": zip_file_name, + "archive_file": archive_file_name, "archive_members": image_file_name, }, ) @@ -481,7 +486,7 @@ def test_extract_file(httpserver, http_client, list_files, delete_file): assert image_file_name in list_files() # Cleanup - delete_file(zip_file_name) + delete_file(archive_file_name) delete_file(image_file_name) diff --git a/python/web/tests/assets/test_image.7z b/python/web/tests/assets/test_image.7z new file mode 100644 index 0000000000000000000000000000000000000000..f9af5b7a8d43082f76fb28c6420d5d9d9cef8a0f GIT binary patch literal 379 zcmXr7+Ou9=hJoew3l8>&3=mKSrL|YuvAqBPpW$XK14I7b|Nj?n|L<<+AzEaa7`S7S z#_6Wz6(5Q5Fn-5GirAwChp%k8M-xd9n`N zEAdQu^fD%R6U&Y7E4tat2Mc`Nc`i;AT(veqcGtO$>Jl-LZ7lpii4YaVmBo6=`MLVR5L5Jdxuh6a1sE8ZBp4VNiWnF{;4g zjFe&qMFs|_gA5Jyj7$vl4E4+{^wTnPQj7Id^2_sb@)J`S82Y1~JpCLqTyhH-85m`l z4}i>sfCeb-bnxno{r4`^PiJ|;75~fL#%4~4{vAh=TS1Mt_I0v}JHLv``hK)^g2;|P z2Q;L3WoADyRD0NGecLFt|GjGGs=!qr9KKFVnCkqd=|*d&Wbe$L7fxIP9DDA+OEErm zT=xA8b30+ruD1I#_+0zHoOv_#*o3O9`Qk+!n=RD8^9$}Xc%Y#DLp$Vxx3}d+#~0$0 zKkU}1f7j1*($;D2^OXI}ecO*sdzjfPcK`YNV?N4_OD3DFVsf{8-zNFw)_u3Yw~WFU zx&9@txtVQ#{;}Me{}pG#lASgkl2v1M4lBzDJjLFLc>iy-#1dv-JP90{{tF&h7vJ literal 0 HcmV?d00001 diff --git a/python/web/tests/assets/test_image.hds.zip b/python/web/tests/assets/test_image.zip similarity index 76% rename from python/web/tests/assets/test_image.hds.zip rename to python/web/tests/assets/test_image.zip index ecd49a5707850a4c2d4ebd42ce9aa3e71cd7e7c1..9d85ff2210051ffed8193829bf4e0c49213c7cda 100644 GIT binary patch literal 1257 zcmWIWW@Zs#-~hs%5@w+ca3H`S&Y-|hl3H96pP8GOo*JK4l%E@4m06&dky0EQ!pp$^ z?~r!#^}{;JXMni0f}4Sng2a>Ory8#>Au4S~@R7%?GW z#~k3z&LQ*4VmT)Z$kPH00p5&EBFu>L23ZbN-oU_;Mi7h4(kH;1l?|kw5eQR(bRO7p E0K*tJ#Q*>R delta 150 zcmaFKd7aZHz?+#xgn`o$|4BTCiBW-IVTH9FHqa$ZWd`PY|4{ME4UdLS-vtdFaWJ&U