From f080f12195f203192c7584c6acea59dfb9480149 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Tue, 31 Aug 2021 13:44:00 +0200
Subject: [PATCH] TST: add tests for caosdb-server#170

---
 tests/test_issues_server.py | 43 +++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/tests/test_issues_server.py b/tests/test_issues_server.py
index 13e10ac..6de33d8 100644
--- a/tests/test_issues_server.py
+++ b/tests/test_issues_server.py
@@ -257,3 +257,46 @@ def test_issue_131():
         "FIND Entity WITH {} > 100.5 €".format(prop.name))]
 
     assert rec.id in result_ids
+
+
+def test_issue_170():
+    """update scalar data type to list data type"""
+    p = db.Property(name="TestProp1", datatype=db.LIST(db.INTEGER))
+    p.value = [1,2]
+    p.insert() # works
+
+    p2 = db.execute_query("FIND TestProp1", unique=True)
+    assert p2.datatype == db.LIST(db.INTEGER)
+    assert p2.value == [1,2]
+
+    p.description = "TestDescription"
+    p.update() # fails
+
+    p2 = db.execute_query("FIND TestProp1", unique=True)
+    assert p2.datatype == db.LIST(db.INTEGER)
+    assert p2.value == [1,2]
+    assert p2.description == "TestDescription"
+
+
+    p = db.Property(name="TestProp2", datatype=db.DOUBLE)
+    p.insert() # works
+
+    p.datatype = db.LIST(db.INTEGER)
+    p.update() # works
+    p2 = db.execute_query("FIND TestProp1", unique=True)
+    assert p2.datatype == db.LIST(db.INTEGER)
+    assert p2.value == [1,2]
+    p2.value = [1, 2]
+    p2.update() # fails
+
+
+    p = db.Property(name="TestProp3", datatype=db.DOUBLE)
+    p.insert() # works
+
+    p.datatype = db.LIST(db.INTEGER)
+    p.value = [1, 2]
+    p.update() # fails
+
+    p2 = db.execute_query("FIND TestProp1", unique=True)
+    assert p2.datatype == db.LIST(db.INTEGER)
+    assert p2.value == [1,2]
-- 
GitLab