Skip to content
Snippets Groups Projects
Commit 6d6a21e5 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

WIP: Continue unit tests

parent b2f3cbe0
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,7 @@ import caosdb as db
from caosdb.common.models import raise_errors
# TODO: Import the relevant error classes once they have been finalized.
from caosdb.exceptions import (AmbiguityException,
AuthorizationException,
AuthorizationException, ContainerError,
EntityDoesNotExistError, EntityError,
EntityHasNoDatatypeError,
TransactionError, UniqueNamesError)
......@@ -134,10 +134,16 @@ def test_unqualified_parents_error():
rec.add_parent(parent)
with raises(TransactionError) as e:
raise_errors(rec)
# TODO: Both direct and indirect children should be in the errors
# list, the only direct child is the UnqualifiedParentsError with
# entity rec and one child of its own; the EntityDoesNotExistError
# with entity parent.
te = e.value
# One direct child, two errors in total
assert len(te.errors) == 1
assert len(te.all_errors) == 2
# UnqualifiedParentsError in Record ...
assert isinstance(te.errors[0], UnqualifiedParentsError)
assert te.errors[0].entity.name == rec.name
# ... caused by non-existing parent
assert isinstance(te.errors[0].errors[0], EntityDoesNotExistError)
assert te.errors[0].errors[0].entity.name == parent.name
def test_unqualified_properties_error():
......@@ -157,7 +163,14 @@ def test_unqualified_properties_error():
rec.add_property(prop1).add_property(prop2)
with raises(TransactionError) as e:
raise_errors(rec)
# TODO: This should result in one direct child with two children.
te = e.value
assert len(te.errors) == 1
upe = te.errors[0]
assert upe.entity.name == rec.name
assert len(upe.errors) == 2
assert {UnqualifiedPropertiesError, EntityError,
EntityDoesNotExistError}.issubset(te.all_errors)
assert upe.get_code == code
# #################### Multiple errors ####################
......@@ -279,3 +292,6 @@ def test_convenience_functions():
for error_t in [EntityDoesNotExistError, UnqualifiedParentsError,
UnqualifiedPropertiesError]:
assert te.has_error(error_t)
# Not, if limitted to direct children
assert not te.has_error(EntityDoesNotExistError,
direct_children_only=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment