Skip to content

Commit

Permalink
move tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Jun 21, 2023
1 parent 2e733f0 commit 74380d3
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 7 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

from ome_types import from_xml

DATA = Path(__file__).parent / "data"
TESTS = Path(__file__).parent.parent
DATA = TESTS / "data"


def test_bad_xml_annotation() -> None:
Expand Down
11 changes: 6 additions & 5 deletions tests/test_model.py → tests/v1/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def true_stem(p):
return p.name.partition(".")[0]


all_xml = list((Path(__file__).parent / "data").glob("*.ome.xml"))
TESTS = Path(__file__).parent.parent
all_xml = list((TESTS / "data").glob("*.ome.xml"))
xml_read = [mark_xfail(f) if true_stem(f) in SHOULD_FAIL_READ else f for f in all_xml]
xml_roundtrip = []
for f in all_xml:
Expand Down Expand Up @@ -102,7 +103,7 @@ def test_from_xml(xml, parser: str, validate: bool, benchmark):
@pytest.mark.parametrize("validate", validate)
def test_from_tiff(benchmark, validate, parser):
"""Test that OME metadata extractions from Tiff headers works."""
_path = Path(__file__).parent / "data" / "ome.tiff"
_path = TESTS / "data" / "ome.tiff"
ome = benchmark(from_tiff, _path, parser=parser, validate=validate)
assert len(ome.images) == 1
assert ome.images[0].id == "Image:0"
Expand Down Expand Up @@ -160,7 +161,7 @@ def canonicalize(xml, strip_empty):
def test_to_xml_with_kwargs(validate, parser):
"""Ensure kwargs are passed to ElementTree"""
ome = from_xml(
Path(__file__).parent / "data" / "example.ome.xml",
TESTS / "data" / "example.ome.xml",
parser=parser,
validate=validate,
)
Expand Down Expand Up @@ -217,14 +218,14 @@ def test_required_missing():
@pytest.mark.parametrize("parser", parser)
@pytest.mark.parametrize("validate", validate)
def test_refs(validate, parser):
xml = Path(__file__).parent / "data" / "two-screens-two-plates-four-wells.ome.xml"
xml = TESTS / "data" / "two-screens-two-plates-four-wells.ome.xml"
ome = from_xml(xml, parser=parser, validate=validate)
assert ome.screens[0].plate_ref[0].ref is ome.plates[0]


@pytest.mark.parametrize("validate", validate)
@pytest.mark.parametrize("parser", parser)
def test_with_ome_ns(validate, parser):
xml = Path(__file__).parent / "data" / "ome_ns.ome.xml"
xml = TESTS / "data" / "ome_ns.ome.xml"
ome = from_xml(xml, parser=parser, validate=validate)
assert ome.experimenters
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion tests/test_widget.py → tests/v1/test_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

nplg = pytest.importorskip("ome_types._napari_plugin")

DATA = Path(__file__).parent / "data"
TESTS = Path(__file__).parent.parent
DATA = TESTS / "data"


@pytest.mark.parametrize("fname", DATA.iterdir(), ids=lambda x: x.stem)
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions tests/v2/test_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import ome_types
import ome_types2.model


def test_names():
new_model = ome_types2.model.OME.__pydantic_model__.schema()
old_model = ome_types.model.OME.schema()
assert set(old_model["properties"]) == set(new_model["properties"])

for key, value in old_model["definitions"].items():
new_props = new_model["definitions"][key]["properties"]
assert set(value["properties"]) == set(new_props)

0 comments on commit 74380d3

Please sign in to comment.