diff --git a/tests/data/df_input.zip b/tests/data/df_input.zip new file mode 100644 index 0000000..47fd79f Binary files /dev/null and b/tests/data/df_input.zip differ diff --git a/tests/data/generate_trusted_result.py b/tests/data/generate_trusted_result.py index 0ac2bf6..898d651 100644 --- a/tests/data/generate_trusted_result.py +++ b/tests/data/generate_trusted_result.py @@ -1,23 +1,29 @@ import glob import os import tempfile +import zipfile -import test_df -import test_lsm import zarr +import test_df +import test_lsm from linc_convert.modalities.df import multi_slice from linc_convert.modalities.lsm import mosaic if __name__ == "__main__": - with tempfile.TemporaryDirectory() as tmp_dir: - test_lsm._write_test_data(tmp_dir) - output_zarr = os.path.join(tmp_dir, "output.zarr") - mosaic.convert(tmp_dir, output_zarr) - zarr.copy_all(zarr.open(output_zarr), zarr.open("data/lsm.zarr.zip", "w")) + with tempfile.TemporaryDirectory() as tmp_dir: test_df._write_test_data(tmp_dir) output_zarr = os.path.join(tmp_dir, "output.zarr") files = glob.glob(os.path.join(tmp_dir, "*.jp2")) + with zipfile.ZipFile("data/df_input.zip", "w") as z: + for file in files: + z.write(file, os.path.basename(file)) multi_slice.convert(files, output_zarr) zarr.copy_all(zarr.open(output_zarr), zarr.open("data/df.zarr.zip", "w")) + + with tempfile.TemporaryDirectory() as tmp_dir: + test_lsm._write_test_data(tmp_dir) + output_zarr = os.path.join(tmp_dir, "output.zarr") + mosaic.convert(tmp_dir, output_zarr) + zarr.copy_all(zarr.open(output_zarr), zarr.open("data/lsm.zarr.zip", "w")) diff --git a/tests/helper.py b/tests/helper.py index f8d521e..242f3d8 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -1,5 +1,3 @@ -""" """ - import numpy as np import zarr diff --git a/tests/test_df.py b/tests/test_df.py index 586f0bd..384b2f4 100644 --- a/tests/test_df.py +++ b/tests/test_df.py @@ -1,22 +1,24 @@ - import glob import os +import zipfile import glymur import numpy as np -from helper import _cmp_zarr_archives +from helper import _cmp_zarr_archives from linc_convert.modalities.df import multi_slice def _write_test_data(directory: str) -> None: for level in range(5): image = np.zeros((1024, 768, 3), dtype=np.uint8) + level * 10 - jp2 = glymur.Jp2k(f"{directory}/{level}.jp2", data=image) + glymur.Jp2k(f"{directory}/{level}.jp2", data=image, ) def test_df(tmp_path): - _write_test_data(tmp_path) + # _write_test_data(tmp_path) + with zipfile.ZipFile("data/df_input.zip", "r") as z: + z.extractall(tmp_path) output_zarr = tmp_path / "output.zarr" files = glob.glob(os.path.join(tmp_path, "*.jp2")) multi_slice.convert(files, str(output_zarr))