From 1e6d6d8524a6abad29f1198b6de01a20e56d7e5a Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Thu, 30 Mar 2023 17:07:29 +0200
Subject: [PATCH] TST: add tests for server #166

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

diff --git a/tests/test_issues_server.py b/tests/test_issues_server.py
index 794ce8c..960af63 100644
--- a/tests/test_issues_server.py
+++ b/tests/test_issues_server.py
@@ -1202,3 +1202,27 @@ def test_144():
     assert isinstance(value, float)
     assert value == 1e23
     assert value == 1e+23
+
+
+def test_166():
+    """https://gitlab.com/caosdb/caosdb-server/-/issues/166"""
+    db.RecordType(name="exists").insert()
+    db.Property(name="exists_property", datatype=db.INTEGER).insert()
+
+    db.RecordType(name="RT1").add_parent("exists").insert()
+    db.RecordType(name="RT2").add_parent("exists").add_property("exists_property", 32453).insert()
+
+    with pytest.raises(TransactionError) as cm:
+        db.Record(name="RT3").add_parent("notexists").insert()
+    assert [e.msg for e in cm.value.errors] == ["Entity has unqualified parents."]
+
+    with pytest.raises(TransactionError) as cm:
+        db.Record(name="RT4").add_parent("exists").add_property("notexists", 234243).insert()
+    assert [e.msg for e in cm.value.errors] == ["Entity has unqualified properties."]
+
+    with pytest.raises(TransactionError) as cm:
+        db.Record(
+            name="RT5").add_parent("notexists").add_property(
+            "exists_property",
+            234243).insert()
+    assert [e.msg for e in cm.value.errors] == ["Entity has unqualified parents."]
-- 
GitLab