diff --git a/unittests/test_error_handling.py b/unittests/test_error_handling.py index 489f3e299a8be1a1e450a3724c1a11c6c0b839c0..2a8437fca9edd7f9b074120f9eb9e3492499730a 100644 --- a/unittests/test_error_handling.py +++ b/unittests/test_error_handling.py @@ -120,6 +120,36 @@ def test_authorization_exception(): assert err.entity.name == ent.name +def test_empty_container_with_error(): + """Has to raise an error, even though container is empty.""" + code = 0 + cont = _add_error_message_to_entity(db.Container(), code) + with raises(TransactionError) as e: + raise_errors(cont) + # No entity errors + assert len(e.value.errors) == 0 + assert e.value.get_container() == cont + assert int(e.value.get_code()) == code + + +def test_faulty_container_with_healthy_entities(): + """Raises a TransactionError without any EntityErrors since only the + container, but none of its entities has an error. + + """ + code = 0 + cont = _add_error_message_to_entity(db.Container(), code) + cont.append(db.Entity("TestHealthyEnt1")) + cont.append(db.Entity("TestHealthyEnt2")) + with raises(TransactionError) as e: + raise_errors(cont) + # No entity errors + assert len(e.value.errors) == 0 + assert len(e.value.entities) == 0 + assert e.value.get_container() == cont + assert int(e.value.get_code()) == code + + # #################### Children with children ####################