diff --git a/src/ome_autogen.py b/src/ome_autogen.py index 4dd97c7b..7420e3b2 100644 --- a/src/ome_autogen.py +++ b/src/ome_autogen.py @@ -76,7 +76,10 @@ def local_import(item_type): def make_dataclass(component) -> List[str]: lines = ["from pydantic.dataclasses import dataclass", ""] - if isinstance(component, XsdType): + # FIXME: Refactor to remove BinData special-case. + if component.local_name == "BinData": + base_type = None + elif isinstance(component, XsdType): base_type = component.base_type else: base_type = component.type.base_type @@ -105,6 +108,9 @@ def make_dataclass(component) -> List[str]: lines += ["_no_default = object()", ""] lines += ["@dataclass", f"class {component.local_name}{base_name}:"] + # FIXME: Refactor to remove BinData special-case. + if component.local_name == "BinData": + lines.append(" value: str") lines += members.lines( indent=1, force_defaults=" = _no_default # type: ignore" @@ -497,7 +503,8 @@ def _abstract_class(self) -> List[str]: return lines def lines(self) -> str: - if not self.is_complex: + # FIXME: Refactor to remove BinData special-case. + if not self.is_complex and self.elem.local_name != "BinData": lines = self._simple_class() elif self.elem.abstract: lines = self._abstract_class() diff --git a/testing/data/ROI.ome.xml b/testing/data/ROI.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/commentannotation.ome.xml b/testing/data/commentannotation.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/filter.ome.xml b/testing/data/filter.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/folders-larger-taxonomy.ome.xml b/testing/data/folders-larger-taxonomy.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/folders-simple-taxonomy.ome.xml b/testing/data/folders-simple-taxonomy.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/hcs.ome.xml b/testing/data/hcs.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/instrument-units-alternate.ome.xml b/testing/data/instrument-units-alternate.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/instrument-units-default.ome.xml b/testing/data/instrument-units-default.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/instrument.ome.xml b/testing/data/instrument.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/mapannotation.ome.xml b/testing/data/mapannotation.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/metadata-only.ome.xml b/testing/data/metadata-only.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/minimum-specification.ome.xml b/testing/data/minimum-specification.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/multi-channel-time-series.ome.xml b/testing/data/multi-channel-time-series.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/multi-channel-z-series-time-series.ome.xml b/testing/data/multi-channel-z-series-time-series.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/multi-channel-z-series.ome.xml b/testing/data/multi-channel-z-series.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/multi-channel.ome.xml b/testing/data/multi-channel.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/no-date.ome.xml b/testing/data/no-date.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/one-screen-one-plate-four-wells.ome.xml b/testing/data/one-screen-one-plate-four-wells.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/single-image.ome.xml b/testing/data/single-image.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/spim.ome.xml b/testing/data/spim.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/tagannotation.ome.xml b/testing/data/tagannotation.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/time-series.ome.xml b/testing/data/time-series.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/timestampannotation-posix-only.ome.xml b/testing/data/timestampannotation-posix-only.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/timestampannotation.ome.xml b/testing/data/timestampannotation.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/transformations-downgrade.ome.xml b/testing/data/transformations-downgrade.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/transformations-upgrade.ome.xml b/testing/data/transformations-upgrade.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/two-screens-two-plates-four-wells.ome.xml b/testing/data/two-screens-two-plates-four-wells.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/xmlannotation-body-space.ome.xml b/testing/data/xmlannotation-body-space.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/xmlannotation-multi-value.ome.xml b/testing/data/xmlannotation-multi-value.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/xmlannotation-svg.ome.xml b/testing/data/xmlannotation-svg.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/z-series-time-series.ome.xml b/testing/data/z-series-time-series.ome.xml old mode 100755 new mode 100644 diff --git a/testing/data/z-series.ome.xml b/testing/data/z-series.ome.xml old mode 100755 new mode 100644 diff --git a/testing/test_autogen.py b/testing/test_autogen.py index b6c291b4..86e5e125 100644 --- a/testing/test_autogen.py +++ b/testing/test_autogen.py @@ -23,8 +23,27 @@ def model(tmp_path_factory): return importlib.import_module(target_dir.name) -SHOULD_PASS = {"example.ome", "small.ome"} -SHOULD_RAISE = {"bad.ome"} +SHOULD_FAIL = { + "ROI", + "commentannotation", + "filter", + "hcs", + "instrument", + "instrument-units-alternate", + "instrument-units-default", + "mapannotation", + "metadata-only", + "spim", + "tagannotation", + "timestampannotation", + "timestampannotation-posix-only", + "transformations-downgrade", + "transformations-upgrade", + "xmlannotation-body-space", + "xmlannotation-multi-value", + "xmlannotation-svg", +} +SHOULD_RAISE = {"bad"} def mark_xfail(fname): @@ -35,16 +54,19 @@ def mark_xfail(fname): ), ) +def true_stem(p): + return p.name.partition(".")[0] + params = [ - f if f.stem in SHOULD_PASS.union(SHOULD_RAISE) else mark_xfail(f) - for f in TESTING_DIR.glob("data/*.xml") + mark_xfail(f) if true_stem(f) in SHOULD_FAIL else f + for f in TESTING_DIR.glob("data/*.ome.xml") ] -@pytest.mark.parametrize("xml", params, ids=lambda x: x.stem) +@pytest.mark.parametrize("xml", params, ids=true_stem) def test_convert_schema(model, xml): - if xml.stem in SHOULD_RAISE: + if true_stem(xml) in SHOULD_RAISE: with pytest.raises(XMLSchemaValidationError): assert from_xml(xml, model.OME) else: