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
257c7faa
Commit
257c7faa
authored
1 year ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Plain Diff
Merge branch 'f-container-delete-reference-dependency' into 'dev'
Miscellaneous URI-too-long tests See merge request
!70
parents
aaef8fda
df8cb239
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!70
Miscellaneous URI-too-long tests
Pipeline
#44750
failed
1 year ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Stage: deploy
Changes
2
Pipelines
23
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
tests/test_error_stuff.py
+72
-48
72 additions, 48 deletions
tests/test_error_stuff.py
with
73 additions
and
48 deletions
CHANGELOG.md
+
1
−
0
View file @
257c7faa
...
...
@@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
*
Tests for
[
caosdb-pylib#90
](
https://gitlab.com/caosdb/caosdb-pylib/-/issues/90
)
:
`Entity.get_parents_recursively()`
did not work for unretrieved
parents.
*
Test for
[
caosdb-server#192
](
https://gitlab.com/caosdb/caosdb-server/-/issues/192
)
*
Test for miscellaneous
*
-too-long errors.
### Changed (for changes in existing functionality)
...
...
This diff is collapsed.
Click to expand it.
tests/test_error_stuff.py
+
72
−
48
View file @
257c7faa
...
...
@@ -30,7 +30,7 @@ Created on 19.02.2015.
@author: tf
"""
import
caosdb
as
h
import
linkahead
as
db
from
caosdb.exceptions
import
(
AmbiguousEntityError
,
EntityDoesNotExistError
,
EntityError
,
EntityHasNoDatatypeError
,
...
...
@@ -42,7 +42,7 @@ import pytest
def
setup_function
(
function
):
try
:
h
.
execute_query
(
"
FIND ENTITY
"
).
delete
()
db
.
execute_query
(
"
FIND ENTITY
"
).
delete
()
except
BaseException
:
pass
...
...
@@ -54,7 +54,7 @@ def teardown_function(function):
def
test_retrieval_no_exception_raised
():
"""
Test whether retrieval fails but error is suppressed.
"""
p
=
h
.
Property
(
name
=
"
TestNon-ExsistentProperty
"
).
retrieve
(
p
=
db
.
Property
(
name
=
"
TestNon-ExsistentProperty
"
).
retrieve
(
unique
=
True
,
raise_exception_on_error
=
False
)
assert
not
p
.
is_valid
()
assert
(
p
.
id
is
None
or
p
.
id
<
0
)
...
...
@@ -67,8 +67,8 @@ def test_retrieval_exception_raised():
"""
propname
=
"
TestNon-ExistentProperty
"
with
pytest
.
raises
(
TransactionError
)
as
te
:
h
.
Property
(
name
=
"
TestNon-ExistentProperty
"
).
retrieve
(
unique
=
True
,
raise_exception_on_error
=
True
)
db
.
Property
(
name
=
"
TestNon-ExistentProperty
"
).
retrieve
(
unique
=
True
,
raise_exception_on_error
=
True
)
assert
len
(
te
.
value
.
errors
)
==
1
ee
=
te
.
value
.
errors
[
0
]
# Check for type incl. inheritance
...
...
@@ -89,19 +89,19 @@ def test_ambiguous_retrieval():
raised correctly if there are two possible candidates.
"""
h
.
RecordType
(
name
=
"
TestType
"
).
insert
()
h
.
Record
(
name
=
"
TestRec
"
).
add_parent
(
name
=
"
TestType
"
).
insert
()
db
.
RecordType
(
name
=
"
TestType
"
).
insert
()
db
.
Record
(
name
=
"
TestRec
"
).
add_parent
(
name
=
"
TestType
"
).
insert
()
# Insert twice, so unique=False
h
.
Record
(
name
=
"
TestRec
"
).
add_parent
(
name
=
"
TestType
"
).
insert
(
unique
=
False
)
db
.
Record
(
name
=
"
TestRec
"
).
add_parent
(
name
=
"
TestType
"
).
insert
(
unique
=
False
)
with
pytest
.
raises
(
TransactionError
)
as
te
:
h
.
Record
(
name
=
"
TestRec
"
).
retrieve
()
db
.
Record
(
name
=
"
TestRec
"
).
retrieve
()
assert
te
.
value
.
has_error
(
AmbiguousEntityError
)
assert
te
.
value
.
errors
[
0
].
entity
.
name
==
"
TestRec
"
def
test_insertion_no_exception_raised
():
"""
Test whether insertion fails but no error is raised.
"""
p
=
h
.
Property
(
name
=
"
TestNoTypeProperty
"
).
insert
(
p
=
db
.
Property
(
name
=
"
TestNoTypeProperty
"
).
insert
(
raise_exception_on_error
=
False
)
assert
not
p
.
is_valid
()
assert
(
p
.
id
is
None
or
p
.
id
<
0
)
...
...
@@ -109,7 +109,7 @@ def test_insertion_no_exception_raised():
def
test_insertion_exception_raised
():
"""
Test insertion of a property with missing datatype.
"""
p
=
h
.
Property
(
name
=
"
TestNoTypeProperty
"
)
p
=
db
.
Property
(
name
=
"
TestNoTypeProperty
"
)
with
pytest
.
raises
(
TransactionError
)
as
te
:
p
.
insert
(
raise_exception_on_error
=
True
)
assert
te
.
value
.
has_error
(
EntityHasNoDatatypeError
)
...
...
@@ -117,7 +117,7 @@ def test_insertion_exception_raised():
def
test_insertion_with_invalid_parents
():
with
pytest
.
raises
(
TransactionError
)
as
te
:
p
=
h
.
Property
(
p
=
db
.
Property
(
name
=
"
TestNoTypeProperty
"
,
datatype
=
"
Text
"
).
add_parent
(
id
=-
1
)
...
...
@@ -136,7 +136,7 @@ def test_insertion_with_invalid_parents():
def
test_insertion_with_invalid_properties
():
with
pytest
.
raises
(
TransactionError
)
as
te
:
p
=
h
.
Property
(
p
=
db
.
Property
(
name
=
"
TestNoTypeProperty
"
,
datatype
=
"
Text
"
).
add_property
(
id
=-
1
)
...
...
@@ -157,11 +157,11 @@ def test_entity_does_not_exist():
EntityDoesNotExistErrors.
"""
p1
=
h
.
Property
(
name
=
"
TestNon-ExistentProperty1
"
).
retrieve
(
p1
=
db
.
Property
(
name
=
"
TestNon-ExistentProperty1
"
).
retrieve
(
raise_exception_on_error
=
False
)
p2
=
h
.
Property
(
name
=
"
TestNon-ExistentProperty2
"
).
retrieve
(
p2
=
db
.
Property
(
name
=
"
TestNon-ExistentProperty2
"
).
retrieve
(
raise_exception_on_error
=
False
)
p3
=
h
.
Property
(
name
=
"
TestNon-ExistentProperty3
"
).
retrieve
(
p3
=
db
.
Property
(
name
=
"
TestNon-ExistentProperty3
"
).
retrieve
(
raise_exception_on_error
=
False
)
# None of them should exist
assert
not
p1
.
is_valid
()
...
...
@@ -171,17 +171,17 @@ def test_entity_does_not_exist():
assert
not
p3
.
is_valid
()
assert
(
p3
.
id
is
None
or
p3
.
id
<
0
)
pe
=
h
.
Property
(
name
=
"
TestExistentProperty
"
,
datatype
=
"
text
"
).
insert
()
pe
=
db
.
Property
(
name
=
"
TestExistentProperty
"
,
datatype
=
"
text
"
).
insert
()
c
=
h
.
Container
().
extend
(
c
=
db
.
Container
().
extend
(
[
h
.
Property
(
db
.
Property
(
name
=
"
TestNon-ExistentProperty1
"
),
h
.
Property
(
db
.
Property
(
name
=
"
TestNon-ExistentProperty2
"
),
h
.
Property
(
db
.
Property
(
name
=
"
TestNon-ExistentProperty3
"
),
h
.
Property
(
db
.
Property
(
name
=
"
TestExistentProperty
"
)])
with
pytest
.
raises
(
TransactionError
)
as
te
:
...
...
@@ -199,11 +199,11 @@ def test_insert_existent_entity():
UniqueNamesError.
"""
p1
=
h
.
Property
(
name
=
"
TestNon-ExistentProperty1
"
).
retrieve
(
p1
=
db
.
Property
(
name
=
"
TestNon-ExistentProperty1
"
).
retrieve
(
raise_exception_on_error
=
False
)
p2
=
h
.
Property
(
name
=
"
TestNon-ExistentProperty2
"
).
retrieve
(
p2
=
db
.
Property
(
name
=
"
TestNon-ExistentProperty2
"
).
retrieve
(
raise_exception_on_error
=
False
)
p3
=
h
.
Property
(
name
=
"
TestNon-ExistentProperty3
"
).
retrieve
(
p3
=
db
.
Property
(
name
=
"
TestNon-ExistentProperty3
"
).
retrieve
(
raise_exception_on_error
=
False
)
# None of them should exist
assert
not
p1
.
is_valid
()
...
...
@@ -213,21 +213,21 @@ def test_insert_existent_entity():
assert
not
p3
.
is_valid
()
assert
(
p3
.
id
is
None
or
p3
.
id
<
0
)
pe
=
h
.
Property
(
name
=
"
TestExistentProperty
"
,
datatype
=
"
text
"
).
insert
()
pe
=
db
.
Property
(
name
=
"
TestExistentProperty
"
,
datatype
=
"
text
"
).
insert
()
assert
pe
.
is_valid
()
c
=
h
.
Container
().
extend
(
c
=
db
.
Container
().
extend
(
[
h
.
Property
(
db
.
Property
(
name
=
"
TestNon-ExistentProperty1
"
,
datatype
=
"
text
"
),
h
.
Property
(
db
.
Property
(
name
=
"
TestNon-ExistentProperty2
"
,
datatype
=
"
text
"
),
h
.
Property
(
db
.
Property
(
name
=
"
TestNon-ExistentProperty3
"
,
datatype
=
"
text
"
),
h
.
Property
(
db
.
Property
(
name
=
"
TestExistentProperty
"
,
datatype
=
"
text
"
)])
...
...
@@ -243,31 +243,31 @@ def test_insert_existent_entity():
def
test_double_insertion
():
c1
=
h
.
Container
()
c1
=
db
.
Container
()
c1
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
TestSimpleTextProperty
"
,
description
=
"
simple text property (from test_error_stuff.py)
"
,
datatype
=
'
text
'
))
c1
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
TestSimpleDoubleProperty
"
,
description
=
"
simple double property (from test_error_stuff.py)
"
,
datatype
=
'
double
'
))
c1
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
TestSimpleIntegerProperty
"
,
description
=
"
simple integer property (from test_error_stuff.py)
"
,
datatype
=
'
integer
'
))
c1
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
TestSimpleDatetimeProperty
"
,
description
=
"
simple datetime property (from test_error_stuff.py)
"
,
datatype
=
'
datetime
'
))
c1
.
append
(
h
.
RecordType
(
db
.
RecordType
(
name
=
"
TestSimpleRecordType
"
,
description
=
"
simple recordType (from test_error_stuff.py)
"
).
add_property
(
name
=
'
TestSimpleTextProperty
'
).
add_property
(
...
...
@@ -277,30 +277,30 @@ def test_double_insertion():
c1
.
insert
()
c2
=
h
.
Container
()
c2
=
db
.
Container
()
c2
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
TestSimpleTextProperty
"
,
description
=
"
simple text property (from test_error_stuff.py)
"
,
datatype
=
'
text
'
))
c2
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
TestSimpleDoubleProperty
"
,
description
=
"
simple double property (from test_error_stuff.py)
"
,
datatype
=
'
double
'
))
c2
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
TestSimpleIntegerProperty
"
,
description
=
"
simple integer property (from test_error_stuff.py)
"
,
datatype
=
'
integer
'
))
c2
.
append
(
h
.
Property
(
db
.
Property
(
name
=
"
TestSimpleDatetimeProperty
"
,
description
=
"
simple datetime property (from test_error_stuff.py)
"
,
datatype
=
'
datetime
'
))
c2
.
append
(
h
.
RecordType
(
db
.
RecordType
(
name
=
"
TestSimpleRecordType
"
,
description
=
"
simple recordType (from test_error_stuff.py)
"
).
add_property
(
name
=
'
TestSimpleTextProperty
'
).
add_property
(
...
...
@@ -322,7 +322,7 @@ def test_update_acl_errors():
`Entity.update_acl`
"""
rec_ne
=
h
.
Record
(
"
TestRecordNonExisting
"
)
rec_ne
=
db
.
Record
(
"
TestRecordNonExisting
"
)
with
pytest
.
raises
(
TransactionError
)
as
te
:
...
...
@@ -331,12 +331,36 @@ def test_update_acl_errors():
assert
te
.
value
.
has_error
(
EntityDoesNotExistError
)
assert
te
.
value
.
errors
[
0
].
entity
.
name
==
rec_ne
.
name
rt
=
h
.
RecordType
(
name
=
"
TestType
"
).
insert
()
rec
=
h
.
Record
(
name
=
"
TestRecord
"
).
add_parent
(
rt
).
insert
()
h
.
Record
(
name
=
rec
.
name
).
add_parent
(
rt
).
insert
(
unique
=
False
)
rt
=
db
.
RecordType
(
name
=
"
TestType
"
).
insert
()
rec
=
db
.
Record
(
name
=
"
TestRecord
"
).
add_parent
(
rt
).
insert
()
db
.
Record
(
name
=
rec
.
name
).
add_parent
(
rt
).
insert
(
unique
=
False
)
with
pytest
.
raises
(
TransactionError
)
as
te
:
h
.
Record
(
name
=
rec
.
name
).
update_acl
()
db
.
Record
(
name
=
rec
.
name
).
update_acl
()
assert
te
.
value
.
has_error
(
AmbiguousEntityError
)
def
test_URI_too_long
():
"""
Some tests for variours URI too long commands.
See for example https://gitlab.indiscale.com/caosdb/src/caosdb-pylib/-/issues/180
"""
short
=
100
uri_long
=
819
header_long
=
815
with
pytest
.
raises
(
db
.
TransactionError
)
as
excinfo
:
db
.
execute_query
(
"
0123456789
"
*
short
)
assert
"
Parsing
"
in
excinfo
.
value
.
msg
with
pytest
.
raises
(
db
.
HTTPURITooLongError
)
as
excinfo
:
db
.
execute_query
(
"
0123456789
"
*
uri_long
)
assert
"
414
"
in
excinfo
.
value
.
msg
with
pytest
.
raises
(
db
.
HTTPURITooLongError
)
as
excinfo
:
db
.
execute_query
(
"
0123456789
"
*
header_long
)
assert
"
431
"
in
excinfo
.
value
.
msg
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