Skip to content

Commit

Permalink
tests: increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jun 20, 2018
1 parent 8689a09 commit f403227
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions tests/test_series_zip_tif_holo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import pathlib
import tempfile
import zipfile

import qpformat


datapath = pathlib.Path(__file__).parent / "data"


def setup_test_zip(num=5):
_fd, name = tempfile.mkstemp(suffix=".zip", prefix="qpformat_test_holo_")
tifname = datapath / "single_holo.tif"
with zipfile.ZipFile(name, mode="w") as arc:
for ii in range(num):
arc.write(tifname, arcname="test_{:04d}.tif".format(ii))
return pathlib.Path(name)


def test_basic():
num = 5
path = setup_test_zip(num)
ds = qpformat.load_data(path)
# basic tests
assert ds.storage_type == "hologram"
assert len(ds) == num
assert ds.is_series
assert ds.path == path
assert "SeriesZipTifHolo" in ds.__repr__()

try:
path.unlink()
except OSError:
pass


def test_identifier():
path = setup_test_zip(1)
ds = qpformat.load_data(path, holo_kw={"sideband": 1})
assert ds.identifier == "641ca"
try:
path.unlink()
except OSError:
pass


def test_load_data():
num = 5
path = setup_test_zip(num)
ds = qpformat.load_data(path)
# basic tests
qpi = ds.get_qpimage(0)
assert qpi.shape == (238, 267)

try:
path.unlink()
except OSError:
pass


if __name__ == "__main__":
# Run all tests
loc = locals()
for key in list(loc.keys()):
if key.startswith("test_") and hasattr(loc[key], "__call__"):
loc[key]()

0 comments on commit f403227

Please sign in to comment.