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

TST: add test case for compare_entities

parent 133c0e36
Branches
Tags
2 merge requests!159Release 0.16.o,!157compare entities and parent/property lists
......@@ -207,7 +207,8 @@ def compare_entities(entity0: Optional[Entity] = None,
If any of these characteristics differ for a property, the respective
string (datatype, importance, value) is added as a key to the dict of the
property with its value being the characteristics value,
e.g. {"prop": {"value": 6, 'importance': 'SUGGESTED'}}.
e.g. {"prop": {"value": 6, 'importance': 'SUGGESTED'}}. Except: None as
value is not added to the dict.
If a property is of type LIST, the comparison is order-sensitive.
Comparison of multi-properties is not yet supported, so should either
......
......@@ -113,13 +113,15 @@ def test_compare_entities():
r2.add_property("tester", )
r1.add_property("tests_234234", value=45)
r2.add_property("tests_TT", value=45)
r1.add_property("datatype", value=45, datatype=db.INTEGER)
r2.add_property("datatype", value=45)
diff_r1, diff_r2 = compare_entities(r1, r2)
assert len(diff_r1["parents"]) == 1
assert len(diff_r2["parents"]) == 0
assert len(diff_r1["properties"]) == 4
assert len(diff_r2["properties"]) == 4
assert len(diff_r1["properties"]) == 5
assert len(diff_r2["properties"]) == 5
assert "test" not in diff_r1["properties"]
assert "test" not in diff_r2["properties"]
......@@ -136,6 +138,11 @@ def test_compare_entities():
assert "tests_234234" in diff_r1["properties"]
assert "tests_TT" in diff_r2["properties"]
assert "datatype" in diff_r1["properties"]
assert "datatype" in diff_r1["properties"]["datatype"]
assert "datatype" in diff_r2["properties"]
assert "datatype" not in diff_r2["properties"]["datatype"]
# test compare units of properties
r1 = db.Record()
r2 = db.Record()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment