From 795768e233d6170db5da9ea97b37d181665747be Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Fri, 16 Jun 2023 12:45:28 +0200
Subject: [PATCH] TEST: Testing removal from list of Nones

---
 unittests/test_property.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/unittests/test_property.py b/unittests/test_property.py
index 42e7d2d3..84f89b5a 100644
--- a/unittests/test_property.py
+++ b/unittests/test_property.py
@@ -146,13 +146,15 @@ def test_remove_value_from_property():
         ("testListProp2", ["a", "b", "a"], db.LIST(db.TEXT)),
         ("testScalarProp1", "bla", db.TEXT),
         ("testScalarProp2", False, db.BOOLEAN),
-        ("testEmptyProp", None, db.REFERENCE)
+        ("testEmptyProp", None, db.REFERENCE),
+        ("testNoneListProp", [None, None], db.LIST(db.REFERENCE)),
     ]
     for name, value, dtype in names_values_dtypes:
         rec.add_property(name=name, value=value, datatype=dtype)
 
     # property doesn't exist, so do nothing
-    rec.remove_value_from_property("nonexisting", "some_value")
+    returned = rec.remove_value_from_property("nonexisting", "some_value")
+    assert returned is rec
     for name, value, dtype in names_values_dtypes:
         assert rec.get_property(name).value == value
         assert rec.get_property(name).datatype == dtype
@@ -162,7 +164,8 @@ def test_remove_value_from_property():
     assert rec.get_property("testListProp1").value == [1, 2, 3]
     assert rec.get_property("testListProp1").datatype == db.LIST(db.INTEGER)
 
-    rec.remove_value_from_property("testScalarProp2", True)
+    returned = rec.remove_value_from_property("testScalarProp2", True)
+    assert returned is rec
     assert rec.get_property("testScalarProp2").value is False
     assert rec.get_property("testScalarProp2").datatype == db.BOOLEAN
 
@@ -211,3 +214,9 @@ def test_remove_value_from_property():
     assert rec.get_property("testEmptyProp") is not None
     assert rec.get_property("testEmptyProp").value is None
     assert rec.get_property("testEmptyProp").datatype == db.REFERENCE
+
+    # Remove `None` from list `[None, None]`
+    rec.remove_value_from_property("testNoneListProp", None, remove_if_empty_afterwards=True)
+    assert rec.get_property("testNoneListProp") is not None
+    assert rec.get_property("testNoneListProp").value == [None]
+    assert rec.get_property("testNoneListProp").datatype == db.LIST(db.REFERENCE)
-- 
GitLab