From a90a2c74f4a37e75e5a84fbd45f8517c834065f4 Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Fri, 15 Dec 2023 14:31:21 +0100
Subject: [PATCH] TEST: Enhanced YAML features.

---
 unittests/test_yaml_model_parser.py | 47 +++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/unittests/test_yaml_model_parser.py b/unittests/test_yaml_model_parser.py
index 1019a93a..c66fef13 100644
--- a/unittests/test_yaml_model_parser.py
+++ b/unittests/test_yaml_model_parser.py
@@ -597,3 +597,50 @@ prop2:
     model = parse_model_from_string(model_string)
     prop2 = model["prop2"]
     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"/>
+}"""
-- 
GitLab