Skip to content
Snippets Groups Projects
Commit 63658ad0 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

FIX: additional checks for unsupported multi-properties were needed

parent 15393549
No related branches found
No related tags found
2 merge requests!107ENH: add entity getters and cached functions,!103Improving the compare_entities functions
Pipeline #36402 passed with warnings
......@@ -293,6 +293,7 @@ def compare_entities(old_entity: Entity, new_entity: Entity,
"Comparison not implemented for multi-properties.")
if len(matching) == 0:
# There is no matching property in new_entity:
olddiff["properties"][prop.name] = {}
elif len(matching) == 1:
newdiff["properties"][prop.name] = {}
......@@ -347,8 +348,14 @@ def compare_entities(old_entity: Entity, new_entity: Entity,
olddiff["properties"].pop(prop.name)
# Check whether there are missing properties in old_entity, additionally
# check for multi-properties that are currently not supported:
for prop in new_entity.properties:
matching = [p for p in new_entity.properties if p.name == prop.name]
if len(matching) > 1:
raise NotImplementedError(
"Comparison not implemented for multi-properties.")
if len([0 for p in old_entity.properties if p.name == prop.name]) == 0:
newdiff["properties"][prop.name] = {}
......
......@@ -331,6 +331,24 @@ def test_multi_properties():
with pytest.raises(NotImplementedError, match=".*multi-properties.*"):
compare_entities(r1, r2)
r1 = db.Record()
r2 = db.Record()
r1.add_property("test", value=4)
r1.add_property("test", value=2)
# That would be expected:
# assert empty_diff(r1, r2)
with pytest.raises(NotImplementedError, match=".*multi-properties.*"):
compare_entities(r1, r2)
r1 = db.Record()
r2 = db.Record()
r2.add_property("test", value=2)
r2.add_property("test", value=5)
# That would be expected:
# assert empty_diff(r1, r2)
with pytest.raises(NotImplementedError, match=".*multi-properties.*"):
compare_entities(r1, r2)
def test_copy_entities():
r = db.Record(name="A")
......
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