From 5cbc9efb8ea8531a0d9892ba7f38b15ef195c2ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Tue, 5 Nov 2024 22:06:51 +0100
Subject: [PATCH] TST: add test case for compare_entities

---
 src/linkahead/apiutils.py  |  3 ++-
 unittests/test_apiutils.py | 11 +++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/linkahead/apiutils.py b/src/linkahead/apiutils.py
index 8293fd9f..fd937215 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 4c529e36..5c9bc920 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()
-- 
GitLab