Skip to content

Commit

Permalink
add from_tiff test (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 authored Sep 15, 2020
1 parent a30d5cb commit a812abb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Binary file added testing/data/ome.tiff
Binary file not shown.
13 changes: 11 additions & 2 deletions testing/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
from xmlschema.validators.exceptions import XMLSchemaValidationError

from ome_types import from_xml, model, to_xml
from ome_types import from_tiff, from_xml, model, to_xml
from ome_types.schema import NS_OME, URI_OME, get_schema

# Import ElementTree from one central module to avoid problems passing Elements around,
Expand Down Expand Up @@ -69,7 +69,7 @@ def true_stem(p):


@pytest.mark.parametrize("xml", xml_read, ids=true_stem)
def test_read(xml):
def test_from_xml(xml):

if true_stem(xml) in SHOULD_RAISE_READ:
with pytest.raises(XMLSchemaValidationError):
Expand All @@ -78,6 +78,15 @@ def test_read(xml):
assert from_xml(xml)


def test_from_tiff():
"""Test that OME metadata extractions from Tiff headers works."""
ome = from_tiff(Path(__file__).parent / "data" / "ome.tiff")
assert len(ome.images) == 1
assert ome.images[0].id == "Image:0"
assert ome.images[0].pixels.size_x == 6
assert ome.images[0].pixels.channels[0].samples_per_pixel == 1


@pytest.mark.parametrize("xml", xml_roundtrip, ids=true_stem)
def test_roundtrip(xml):
"""Ensure we can losslessly round-trip XML through the model and back."""
Expand Down

0 comments on commit a812abb

Please sign in to comment.