Skip to content
Snippets Groups Projects
Verified Commit a90a2c74 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

TEST: Enhanced YAML features.

parent dbb2c0f3
No related branches found
No related tags found
3 merge requests!100WIP: Filling XLSX: Seems to be working.,!94ENH: add framework for converting json schema into table templates,!93Filling XLSX: Everything except multiple choice.
Pipeline #44998 passed
...@@ -597,3 +597,50 @@ prop2: ...@@ -597,3 +597,50 @@ prop2:
model = parse_model_from_string(model_string) model = parse_model_from_string(model_string)
prop2 = model["prop2"] prop2 = model["prop2"]
assert prop2.role == "Property" assert prop2.role == "Property"
def test_fancy_yaml():
"""Testing aliases and other fancy YAML features."""
# Simple aliasing
model_string = """
foo:
datatype: INTEGER
RT1:
obligatory_properties: &RT1_oblig
foo:
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>
}"""
# Aliasing with override
model_string = """
foo:
datatype: INTEGER
RT1:
obligatory_properties: &RT1_oblig
foo:
RT2:
obligatory_properties:
<<: *RT1_oblig
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"/>
}"""
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment