Skip to content
Snippets Groups Projects
Commit 5cba7ecf authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

Merge branch 'f-fix-ref-prop' into 'dev'

Fix treatment of reference properties in yml parser

See merge request caosdb/caosdb-advanced-user-tools!88
parents 529aa5ca 132a994b
No related branches found
No related tags found
1 merge request!22Release 0.3
Pipeline #14618 failed
......@@ -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:
......
......@@ -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,
......
......@@ -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."""
......
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