Files
openpipeline_spatial/src/convert/from_xenium_to_spatialdata/test.py
CI c6296af264 Build branch openpipeline_spatial/h5mu-to-seurat with version h5mu-to-seurat to openpipeline_spatial on branch h5mu-to-seurat (3b5314b)
Build pipeline: test-vsh-ci-build-template-qlrkg

Source commit: 3b5314b60d

Source message: update changelog
2025-10-20 09:17:46 +00:00

70 lines
2.3 KiB
Python

import pytest
import os
import sys
import spatialdata as sd
import subprocess
def test_simple_execution(run_component, tmp_path):
output_sd_path = tmp_path / "sd"
run_component(
[
"--input",
meta["resources_dir"] + "/xenium_tiny",
"--output",
output_sd_path,
]
)
assert os.path.exists(output_sd_path), "Output zarr folder was not created"
sdata = sd.read_zarr(output_sd_path)
assert isinstance(sdata, sd.SpatialData), (
"the generated output is not a SpatialData object"
)
assert os.path.exists(output_sd_path / "images"), "images folder was not created"
assert os.path.exists(output_sd_path / "labels"), "labels folder was not created"
assert os.path.exists(output_sd_path / "points"), "images folder was not created"
assert os.path.exists(output_sd_path / "shapes"), "shapes folder was not created"
assert os.path.exists(output_sd_path / "tables"), "tables folder was not created"
assert (output_sd_path / "zmetadata").is_file(), "zmetadata file was not created"
def test_compressed_input(run_component, tmp_path):
output_sd_path = tmp_path / "sd"
zipped_input = tmp_path / "xenium_tiny.zip"
subprocess.run(
["zip", "-r", str(zipped_input), "xenium_tiny"],
cwd=meta["resources_dir"],
check=True,
)
run_component(
[
"--input",
zipped_input,
"--output",
output_sd_path,
]
)
assert os.path.exists(output_sd_path), "Output zarr folder was not created"
sdata = sd.read_zarr(output_sd_path)
assert isinstance(sdata, sd.SpatialData), (
"the generated output is not a SpatialData object"
)
assert os.path.exists(output_sd_path / "images"), "images folder was not created"
assert os.path.exists(output_sd_path / "labels"), "labels folder was not created"
assert os.path.exists(output_sd_path / "points"), "images folder was not created"
assert os.path.exists(output_sd_path / "shapes"), "shapes folder was not created"
assert os.path.exists(output_sd_path / "tables"), "tables folder was not created"
assert (output_sd_path / "zmetadata").is_file(), "zmetadata file was not created"
if __name__ == "__main__":
sys.exit(pytest.main([__file__]))