diff --git a/integrationtests/model.yml b/integrationtests/model.yml index ab302f089de8ddc1782c075ad8ee26ea1259fee2..e1753a9f84d6eff7a9a59c5d17ca4f9f9da7c4c6 100644 --- a/integrationtests/model.yml +++ b/integrationtests/model.yml @@ -9,6 +9,7 @@ Experiment: # TODO empty recommended_properties is a problem #recommended_properties: responsible: + datatype: LIST<Person> Project: SoftwareVersion: recommended_properties: @@ -30,8 +31,6 @@ Person: email: datatype: TEXT description: 'Email of a Person.' -responsible: - datatype: REFERENCE revisionOf: datatype: REFERENCE results: diff --git a/src/caosadvancedtools/models/parser.py b/src/caosadvancedtools/models/parser.py index 1eda090757336506436621f9f430cf852a8a2348..e56a492fa3e9199a312d374a622770e7836f42cb 100644 --- a/src/caosadvancedtools/models/parser.py +++ b/src/caosadvancedtools/models/parser.py @@ -252,9 +252,8 @@ class Parser(object): # is it a property and "datatype" in definition # but not simply an RT of the model - and not (definition["datatype"] in self.model - or _get_listdatatype( - definition["datatype"]) in self.model)): + and not (_get_listdatatype(definition["datatype"]) == name and + _get_listdatatype(definition["datatype"]) in self.model)): # and create the new property self.model[name] = db.Property(name=name, diff --git a/unittests/test_parser.py b/unittests/test_parser.py index 44b01a3ab2af741497e68cb7a3b912f433d6fe35..161e2873a9c01f9ce415818116b9e4cf9aeadb5c 100644 --- a/unittests/test_parser.py +++ b/unittests/test_parser.py @@ -274,6 +274,22 @@ A: parse_model_from_string(yaml) self.assertIn("line 3", yde.exception.args[0]) + def test_reference_property(self): + """Test correct creation of reference property using an RT.""" + modeldef = """A: + recommended_properties: + ref: + datatype: LIST<A> +""" + model = parse_model_from_string(modeldef) + self.assertEqual(len(model), 2) + for key in model.keys(): + if key == "A": + self.assertTrue(isinstance(model[key], db.RecordType)) + elif key == "ref": + self.assertTrue(isinstance(model[key], db.Property)) + self.assertEqual(model[key].datatype, "LIST<A>") + class ExternTest(unittest.TestCase): """TODO Testing the "extern" keyword in the YAML."""