diff --git a/tests/test_error_stuff.py b/tests/test_error_stuff.py index b970a117302f1f93f1586ae6c48f1268bc786679..899da807a0c10fc909f8cc8a1c5921e2a8699dcb 100644 --- a/tests/test_error_stuff.py +++ b/tests/test_error_stuff.py @@ -31,13 +31,11 @@ Created on 19.02.2015. """ import caosdb as h -from caosdb.exceptions import (ContainerError, - EntityDoesNotExistError, +from caosdb.exceptions import (EntityDoesNotExistError, EntityError, EntityHasNoDatatypeError, - UniqueNamesError, TransactionError, - EntityError, - UnqualifiedPropertiesError, - UnqualifiedParentsError) + TransactionError, UniqueNamesError, + UnqualifiedParentsError, + UnqualifiedPropertiesError) import pytest @@ -75,11 +73,8 @@ def test_retrieval_exception_raised(): with pytest.raises(TransactionError) as te: h.Property(name="TestNon-ExistentProperty").retrieve(unique=True, raise_exception_on_error=True) - # retrieve returns a container, so treat that one separately - ce = te.value.get_errors()[0] - assert isinstance(ce, ContainerError) - assert len(ce.get_errors()) == 1 - ee = ce.get_errors()[0] + assert len(te.value.get_errors()) == 1 + ee = te.value.get_errors()[0] # Check for type incl. inheritance assert isinstance(ee, EntityDoesNotExistError) assert isinstance(ee, EntityError) @@ -112,9 +107,7 @@ def test_insertion_with_invalid_parents(): datatype="Text").add_parent( id=-1) p.insert(raise_exception_on_error=True) - # TransactionError with ContainerError with - # UnqualifiedParentsError - upe = te.value.get_errors()[0].get_errors()[0] + upe = te.value.get_errors()[0] print(upe) assert isinstance(upe, UnqualifiedParentsError) assert not upe.get_entity() is None @@ -133,9 +126,7 @@ def test_insertion_with_invalid_properties(): datatype="Text").add_property( id=-1) p.insert(raise_exception_on_error=True) - # TransactionError with ContainerError with - # UnqualifiedPropertiesError - upe = te.value.get_errors()[0].get_errors()[0] + upe = te.value.get_errors()[0] assert isinstance(upe, UnqualifiedPropertiesError) assert not upe.get_entity() is None assert upe.get_entity().name == p.name @@ -183,11 +174,9 @@ def test_entity_does_not_exist(): te = te.value assert te.has_error(EntityDoesNotExistError) # Only non-existing entities caused the container error - assert not pe.name in [x.name for x in - te.get_errors()[0].get_all_entities()] + assert not pe.name in [x.name for x in te.get_all_entities()] for p in (p1, p2, p3): - assert p.name in [x.name for x in - te.get_errors()[0].get_all_entities()] + assert p.name in [x.name for x in te.get_all_entities()] def test_insert_existent_entity(): @@ -231,7 +220,7 @@ def test_insert_existent_entity(): c.insert(unique=True) te = te.value assert te.has_error(UniqueNamesError) - une = te.get_errors()[0].get_errors()[0] + une = te.get_errors()[0] assert not une.get_entity() is None assert pe.name == une.get_entity().name for p in (p1, p2, p3): @@ -308,6 +297,6 @@ def test_double_insertion(): te = te.value assert te.has_error(UniqueNamesError) # c2 caused the ContainerError - assert te.get_errors()[0].get_entity() == c2 + assert te.get_container() == c2 # exactly 5 faulty entities in c2 - assert len(te.get_errors()[0].get_entities()) == 5 + assert len(te.get_entities()) == 5