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
af6cdb84
Commit
af6cdb84
authored
4 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
TST: Finish unit test
parent
16dcabcf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_error_handling.py
+32
-9
32 additions, 9 deletions
unittests/test_error_handling.py
with
32 additions
and
9 deletions
unittests/test_error_handling.py
+
32
−
9
View file @
af6cdb84
...
...
@@ -148,7 +148,7 @@ def test_unqualified_parents_error():
assert
isinstance
(
te
.
errors
[
0
].
errors
[
0
],
EntityDoesNotExistError
)
assert
te
.
errors
[
0
].
errors
[
0
].
entity
.
name
==
parent
.
name
@pytest.mark.xfail
def
test_unqualified_properties_error
():
"""
Code 114; properties do not exist or have wrong data types or
values.
...
...
@@ -171,14 +171,14 @@ def test_unqualified_properties_error():
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
for
error_t
in
[
UnqualifiedPropertiesError
,
EntityError
,
EntityDoesNotExistError
]:
assert
any
([
isinstance
(
x
,
error_t
)
for
x
in
te
.
all_errors
])
assert
upe
.
get_code
()
==
code
# #################### Multiple errors ####################
@pytest.mark.xfail
def
test_parent_and_properties_errors
():
"""
Record with UnqualifiedParentsError and UnqualifiedPropertiesError,
and corresponding parent and properties with their errors as
...
...
@@ -204,8 +204,33 @@ def test_parent_and_properties_errors():
raise_errors
(
rec
)
# TODO: Now there should be two direct children; both have to be
# displayed correctly.
te
=
e
.
value
# exactly two children:
assert
len
(
te
.
errors
)
==
2
# both have to have the right codes and entities
found_parent
=
False
found_prop
=
False
for
err
in
te
.
errors
:
if
err
.
get_code
()
==
parent_code
:
found_parent
=
True
assert
err
.
errors
[
0
].
entity
.
name
==
parent
.
name
assert
not
prop1
.
name
in
[
x
.
name
for
x
in
err
.
all_entities
]
assert
not
prop2
.
name
in
[
x
.
name
for
x
in
err
.
all_entities
]
elif
err
.
get_code
()
==
prop_code
:
found_prop
=
True
assert
not
parent
.
name
in
[
x
.
name
for
x
in
err
.
all_entities
]
for
sub_err
in
err
.
errors
:
if
sub_err
.
get_code
()
==
entity_code
:
assert
sub_err
.
entity
.
name
==
prop1
.
name
elif
sub_err
.
get_code
()
==
no_entity_code
:
assert
sub_err
.
entity
.
name
==
prop2
.
name
assert
found_parent
assert
found_prop
@pytest.mark.xfail
def
test_container_with_faulty_elements
():
"""
Code 12; container with valid and invalid entities. All faulty
entities have to be reflected correctly in the errors list of the
...
...
@@ -235,7 +260,7 @@ def test_container_with_faulty_elements():
# broken records with single and multiole errors
rec_name
=
_add_error_message_to_entity
(
db
.
Record
(
name
=
"
TestRecord2
"
),
code
=
name_code
)
rec_auth
=
_add_error_message_to_entity
(
db
.
Record
(
name
=
"
TestRecord
2
"
),
rec_auth
=
_add_error_message_to_entity
(
db
.
Record
(
name
=
"
TestRecord
3
"
),
code
=
auth_code
)
rec_par_prop
=
_add_error_message_to_entity
(
db
.
Record
(
name
=
"
TestRecord
"
),
prop_code
)
...
...
@@ -245,8 +270,6 @@ def test_container_with_faulty_elements():
cont
.
extend
([
rec_name
,
rec_auth
,
rec_par_prop
])
with
raises
(
TransactionError
)
as
e
:
raise_errors
(
cont
)
# TODO: Check whether all errors and all broken entities are
# listed correctly. The healthy entities must not appear.
te
=
e
.
value
# only container on first level:
assert
len
(
te
.
errors
)
==
1
...
...
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