diff --git a/unittests/test_error_handling.py b/unittests/test_error_handling.py index deb3c18d0154f9fb3f4fbe5059857184377d6f14..1ff596b47d8d2a681186d6d4704676ef80abb7d2 100644 --- a/unittests/test_error_handling.py +++ b/unittests/test_error_handling.py @@ -204,11 +204,12 @@ def test_parent_and_properties_errors(): def test_container_with_faulty_elements(): - """Container with valid and invalid entities. All faulty entities have - to be reflected correctly in the errors list of the + """Code 12; container with valid and invalid entities. All faulty + entities have to be reflected correctly in the errors list of the TransactionError raised by the container. """ + container_code = 12 prop_code = 114 parent_code = 116 name_code = 152 @@ -222,7 +223,8 @@ def test_container_with_faulty_elements(): name="TestProp1"), entity_code) prop2 = _add_error_message_to_entity(db.Property( name="TestProp2"), no_entity_code) - cont = db.Container() + cont = _add_error_message_to_entity(db.Container(), + container_code) # healthy record and property good_rec = db.Record(name="TestRecord1") good_prop = db.Property(name="TestProp3") @@ -242,6 +244,15 @@ def test_container_with_faulty_elements(): raise_errors(cont) # TODO: Check whether all errors and all broken entities are # listed correctly. The healthy entities must not appear. + te = e.value + # only container on first level: + assert len(te.errors) == 1 + ce = te.errors[0] + assert isinstance(ce, ContainerError) + # no healthy entity caused an error + for good in [good_rec, good_prop]: + assert not good in te.all_errors + def test_convenience_functions():