Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
6d6a21e5
Commit
6d6a21e5
authored
4 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: Continue unit tests
parent
b2f3cbe0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_error_handling.py
+22
-6
22 additions, 6 deletions
unittests/test_error_handling.py
with
22 additions
and
6 deletions
unittests/test_error_handling.py
+
22
−
6
View file @
6d6a21e5
...
...
@@ -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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment