From 9a5e01c3e0600a45517a38ba60ab59d1fa9b4f79 Mon Sep 17 00:00:00 2001
From: Alexander Schlemmer <alexander@mail-schlemmer.de>
Date: Thu, 16 Dec 2021 14:07:33 +0100
Subject: [PATCH] TST: added a test for units in compare_entities

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

diff --git a/unittests/test_apiutils.py b/unittests/test_apiutils.py
index 717595d0..9cf9e1b7 100644
--- a/unittests/test_apiutils.py
+++ b/unittests/test_apiutils.py
@@ -144,3 +144,38 @@ def test_compare_entities():
 
     assert "tests_234234" in diff_r1["properties"]
     assert "tests_TT" in diff_r2["properties"]
+
+    
+def test_compare_entities_units():
+    r1 = db.Record()
+    r2 = db.Record()
+    r1.add_parent("bla")
+    r2.add_parent("bla")
+    r1.add_parent("lopp")
+    r1.add_property("test", value=2, unit="cm")
+    r2.add_property("test", value=2, unit="m")
+    r1.add_property("tests", value=3, unit="cm")
+    r2.add_property("tests", value=45, unit="cm")
+    r1.add_property("tester", value=3)
+    r2.add_property("tester", )
+    r1.add_property("tests_234234", value=45, unit="cm")
+    r2.add_property("tests_TT", value=45, unit="cm")
+
+    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 "tests" in diff_r1["properties"]
+    assert "tests" in diff_r2["properties"]
+
+    assert "tester" in diff_r1["properties"]
+    assert "tester" in diff_r2["properties"]
+
+    assert "tests_234234" in diff_r1["properties"]
+    assert "tests_TT" in diff_r2["properties"]
+
+    assert diff_r1["properties"]["test"]["unit"] == "cm"
+    assert diff_r2["properties"]["test"]["unit"] == "m"
-- 
GitLab