From 1e2bd9af874a7fa40f8ca1af889635d7cbb1ad6f Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Thu, 17 Jun 2021 14:29:08 +0200
Subject: [PATCH] add another test for illegal values of the force-missing-obl
 flag

---
 tests/test_importance.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tests/test_importance.py b/tests/test_importance.py
index 1536f1e..6a53cdb 100644
--- a/tests/test_importance.py
+++ b/tests/test_importance.py
@@ -146,3 +146,21 @@ def test_sub_property_of_obl_in_same_container():
     c = db.Container()
     c.extend([rt2, p2])
     c.insert()  # everything ok!
+
+def test_illegal_flag_value():
+    p = db.Property(name="TestOblProperty", datatype=db.TEXT).insert()
+    p_dummy = db.Property(name="TestDummyProperty", datatype=db.TEXT).insert()
+
+    rt1 = db.RecordType(name="TestRecordType1")
+    rt1.add_property(name="TestOblProperty", importance=db.OBLIGATORY)
+    rt1.insert()
+
+    rt2 = db.RecordType(name="TestRecordType2")
+    rt2.add_parent("TestRecordType1", inheritance=db.NONE)
+    rt2.add_property("TestDummyProperty")
+    rt2.set_flag("force-missing-obligatory", "illegal!!!!")
+    with raises(db.TransactionError) as exc:
+        rt2.insert()
+    # default behavior + warning
+    assert exc.value.errors[0].msg == "An obligatory property is missing."
+    assert "Illegal value for flag 'force-missing-obligatory'." in [w.description for w in rt2.get_warnings()]
-- 
GitLab