From cf25e10b88f5110ac3641e12ea1ca33143d1e1d2 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Thu, 17 Jun 2021 14:44:48 +0200 Subject: [PATCH] STY: autopep8'ed test_importance --- tests/test_importance.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/test_importance.py b/tests/test_importance.py index 6a53cdb..f7d4794 100644 --- a/tests/test_importance.py +++ b/tests/test_importance.py @@ -99,12 +99,23 @@ def test_obl_missing_parent_in_same_container(): c = db.Container() c.extend([rt1, rt2]) - # with raises(db.TransactionError) as exc: - # c.insert() - # assert exc.value == "asdf" + with raises(db.TransactionError) as exc: + c.insert() + assert exc.value.errors[0].msg == "An obligatory property is missing." + + +def test_obl_missing_parent_in_same_container_override(): + p = db.Property(name="TestOblProperty", datatype=db.TEXT).insert() + + rt1 = db.RecordType(name="TestRecordType1") + rt1.add_property(name="TestOblProperty", importance=db.OBLIGATORY) - # set container flag, override in rt2 (entity flag takes precedence here) + rt2 = db.RecordType(name="TestRecordType2") + rt2.add_parent("TestRecordType1", inheritance=db.NONE) rt2.set_flag("force-missing-obligatory", "error") + + c = db.Container() + c.extend([rt1, rt2]) with raises(db.TransactionError) as exc: c.insert(flags={"force-missing-obligatory": "ignore"}) assert exc.value.errors[0].msg == "An obligatory property is missing." @@ -147,6 +158,7 @@ def test_sub_property_of_obl_in_same_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() @@ -163,4 +175,5 @@ def test_illegal_flag_value(): 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()] + assert "Illegal value for flag 'force-missing-obligatory'." in [ + w.description for w in rt2.get_warnings()] -- GitLab