From 60b2af83e51bea568fbcb0de1290569640f88afc Mon Sep 17 00:00:00 2001
From: florian <f.spreckelsen@inidscale.com>
Date: Fri, 10 Jul 2020 13:52:35 +0200
Subject: [PATCH] TST: Add container error tests

---
 unittests/test_error_handling.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/unittests/test_error_handling.py b/unittests/test_error_handling.py
index 489f3e29..2a8437fc 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 ####################
 
 
-- 
GitLab