From da07a1d7dc29384b6608be9567364ecd082361f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Wed, 6 Nov 2024 11:25:37 +0100
Subject: [PATCH] TST: add test cases for compare entities

---
 unittests/test_apiutils.py | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/unittests/test_apiutils.py b/unittests/test_apiutils.py
index 4690fa6e..73cbddd8 100644
--- a/unittests/test_apiutils.py
+++ b/unittests/test_apiutils.py
@@ -185,6 +185,43 @@ def test_compare_entities():
     assert "entity_Ent_d" in diff_r1["properties"]
     assert "entity_Ent_d" in diff_r2["properties"]
 
+#    diff_r1, diff_r2 = compare_entities(r1, r2,
+#                                        entity_name_id_equivalency=True,
+#                                        compare_referenced_records=True)
+#
+#    assert len(diff_r1["parents"]) == 1
+#    assert len(diff_r2["parents"]) == 0
+#    assert len(diff_r1["properties"]) == 9
+#    assert len(diff_r2["properties"]) == 9
+#
+#    assert "entity_id" in diff_r1["properties"]
+#    assert "entity_id" in diff_r2["properties"]
+#
+#    assert "entity_mix_e" not in diff_r1["properties"]
+#    assert "entity_mix_e" not in diff_r2["properties"]
+#    assert "entity_mix_w" in diff_r1["properties"]
+#    assert "entity_mix_w" in diff_r2["properties"]
+#    assert "entity_Ent_e" not in diff_r1["properties"]
+#    assert "entity_Ent_e" not in diff_r2["properties"]
+#
+#    assert "entity_mix_d" in diff_r1["properties"]
+#    assert "entity_mix_d" in diff_r2["properties"]
+#    assert "entity_Ent_d" in diff_r1["properties"]
+#    assert "entity_Ent_d" in diff_r2["properties"]
+
+    r1 = db.Record()
+    r2 = db.Record()
+    r1.add_property(id=20, name="entity_mix_d", value=2, datatype=db.LIST("B"))
+    r2.add_property("entity_mix_d", value=db.Entity())
+
+    diff_r1, diff_r2 = compare_entities(r1, r2, compare_referenced_records=True)
+
+    assert len(diff_r1["properties"]) == 1
+    assert len(diff_r2["properties"]) == 1
+
+    assert "entity_mix_d" in diff_r1["properties"]
+    assert "entity_mix_d" in diff_r2["properties"]
+
 
 def test_compare_entities_units():
     r1 = db.Record()
-- 
GitLab