Skip to content
Snippets Groups Projects
Commit bc112cf6 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

FIX: Don't ignore top-level description or unit if datatype is given

parent ed483239
No related branches found
No related tags found
2 merge requests!128MNT: Added a warning when column metadata is not configured, and a better...,!115add datatype, unit and description to properties that are part of Records
Pipeline #57882 passed
......@@ -351,25 +351,20 @@ debug : bool, optional
if prop.name in self.model:
model_prop = self.model[prop.name]
# The information must be missing, we don't want to overwrite it accidentally:
if prop.datatype is not None and prop.datatype != model_prop.datatype:
continue
# TODO: Data type overwrite is allowed here (because
# of lists), but this might change in the future.
# raise RuntimeError("datatype must not be set, here. This is probably a bug.")
if prop.unit is not None and prop.unit != model_prop.unit:
continue
if prop.description is not None and prop.description != model_prop.description:
continue
# If this property has a more detailed definition in the model,
# copy over the information:
if isinstance(model_prop, db.RecordType):
# in this case the datatype equals the name of the record type:
prop.datatype = prop.name
else:
prop.datatype = model_prop.datatype
prop.unit = model_prop.unit
if prop.datatype is None:
if isinstance(model_prop, db.RecordType):
prop.datatype = model_prop.name
else:
prop.datatype = model_prop.datatype
# TODO: Data type overwrite is allowed here (because
# of lists), but this might change in the future.
# elif prop.datatype != model_prop.datatype:
# raise RuntimeError("datatype must not be set, here. This is probably a bug.")
if prop.unit is None:
# No unit for plain reference properties
if not isinstance(model_prop, db.RecordType):
prop.unit = model_prop.unit
if prop.description is None:
prop.description = model_prop.description
return DataModel(self.model.values())
......
......@@ -657,9 +657,11 @@ RT1:
obligatory_properties:
foo:
RT2:
datatype: LIST<RT2>
test_reference:
RT2:
description: Describe RT2
test_reference:
datatype: RT2
......@@ -681,10 +683,10 @@ test_reference:
<RecordType id="2273" name="RT1">
<Version id="0c1b9df6677ee40d1e1429b2123e078ee6c863e0" head="true"/>
<Property id="2272" name="foo" description="bla bla" datatype="INTEGER" unit="m" importance="OBLIGATORY" flag="inheritance:FIX"/>
<Property id="2274" name="RT2" datatype="RT2" importance="OBLIGATORY" flag="inheritance:FIX"/>
<Property id="2274" name="RT2" description="Describe RT2" datatype="LIST&lt;RT2&gt;" importance="OBLIGATORY" flag="inheritance:FIX"/>
<Property id="2275" name="test_reference" datatype="RT2" importance="OBLIGATORY" flag="inheritance:FIX"/>
</RecordType>
<RecordType id="2274" name="RT2">
<RecordType id="2274" name="RT2" description="Describe RT2">
<Version id="185940642680a7eba7f71914dd8dd7758dd13faa" head="true"/>
</RecordType>
<Property id="2275" name="test_reference" datatype="RT2">
......@@ -699,13 +701,32 @@ test_reference:
c3 = compare_entities(model["RT2"], entities[2])
c4 = compare_entities(model["test_reference"], entities[3])
# Make sure the mock response matches the datamodel definiton
# exactly, i.e., they only differ in ids which are None for all
# entities from the datamodel and not None for the mocked
# response.
for cs in (c1, c2, c3, c4):
assert "id" in cs[0]
assert cs[0]["id"] is None
assert cs[0]["parents"] == []
for name, val in cs[0]["properties"].items():
# Also properties differ in ids: The one from the
# datamodel have None
assert len(val) == 1
assert "id" in val
assert val["id"] is None
assert "id" in cs[1]
assert cs[1]["id"] is not None
assert cs[1]["parents"] == []
for name, val in cs[1]["properties"].items():
# Also properties differ in ids: The one from the
# mock response have not None
assert len(val) == 1
assert "id" in val
assert val["id"] is not None
# The server response would be the same as the xml above:
def get_existing_entities(ent_cont):
return entities
......
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