diff --git a/src/linkahead/apiutils.py b/src/linkahead/apiutils.py index 8293fd9f6d4fb996c146f1559a0c6a714beddcfc..fd937215bce92048fc73ab53d46ca51ef3e617fc 100644 --- a/src/linkahead/apiutils.py +++ b/src/linkahead/apiutils.py @@ -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 diff --git a/unittests/test_apiutils.py b/unittests/test_apiutils.py index 4c529e36a86474500cbaf911df932a89af592d77..5c9bc920f1ed02060b7ff25f6d41151f41d81731 100644 --- a/unittests/test_apiutils.py +++ b/unittests/test_apiutils.py @@ -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()