From 18ccd72dcfbeea1e62affa9d1fa1e3e32650fbe1 Mon Sep 17 00:00:00 2001 From: Alexander Schlemmer <a.schlemmer@indiscale.com> Date: Mon, 18 Nov 2024 13:01:21 +0100 Subject: [PATCH] TST(data-model-parser): replaced static xml tests by more specific ones --- unittests/test_yaml_model_parser.py | 32 +++++++++++++---------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/unittests/test_yaml_model_parser.py b/unittests/test_yaml_model_parser.py index e3e9a0af..cf999789 100644 --- a/unittests/test_yaml_model_parser.py +++ b/unittests/test_yaml_model_parser.py @@ -612,14 +612,13 @@ RT2: obligatory_properties: *RT1_oblig """ model = parse_model_from_string(model_string) - assert str(model) == """{'foo': <Property name="foo" datatype="INTEGER"/> -, 'RT1': <RecordType name="RT1"> - <Property name="foo" importance="OBLIGATORY" flag="inheritance:FIX"/> -</RecordType> -, 'RT2': <RecordType name="RT2"> - <Property name="foo" importance="OBLIGATORY" flag="inheritance:FIX"/> -</RecordType> -}""" + + assert len(model) == 3 + assert isinstance(model["foo"], db.Property) + assert model["foo"].datatype == db.INTEGER + for st in ("RT1", "RT2"): + assert isinstance(model[st], db.RecordType) + assert model[st].get_property("foo").datatype == db.INTEGER # Aliasing with override model_string = """ @@ -634,16 +633,13 @@ RT2: bar: """ model = parse_model_from_string(model_string) - assert str(model) == """{'foo': <Property name="foo" datatype="INTEGER"/> -, 'RT1': <RecordType name="RT1"> - <Property name="foo" importance="OBLIGATORY" flag="inheritance:FIX"/> -</RecordType> -, 'RT2': <RecordType name="RT2"> - <Property name="foo" importance="OBLIGATORY" flag="inheritance:FIX"/> - <Property name="bar" importance="OBLIGATORY" flag="inheritance:FIX"/> -</RecordType> -, 'bar': <RecordType name="bar"/> -}""" + + assert len(model) == 4 + assert isinstance(model["bar"], db.RecordType) + for st in ("RT1", "RT2"): + assert isinstance(model[st], db.RecordType) + assert model[st].get_property("foo").datatype == db.INTEGER + assert model["RT2"].get_property("bar").datatype == "bar" def test_comparison_yaml_model(capfd): -- GitLab