From c35eb3af0fb9a823a2c1bb638d10763c7fa29caf Mon Sep 17 00:00:00 2001 From: fspreck <f.spreckelsen@indiscale.com> Date: Fri, 3 Jul 2020 16:36:29 +0200 Subject: [PATCH] ENH: Include container error code --- unittests/test_error_handling.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/unittests/test_error_handling.py b/unittests/test_error_handling.py index deb3c18d..1ff596b4 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(): -- GitLab