Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CaosDB Python Integration Tests
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 Python Integration Tests
Commits
0894e08b
Commit
0894e08b
authored
4 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
Remove ContainerError again
parent
624e95cf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_error_stuff.py
+13
-24
13 additions, 24 deletions
tests/test_error_stuff.py
with
13 additions
and
24 deletions
tests/test_error_stuff.py
+
13
−
24
View file @
0894e08b
...
...
@@ -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
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