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
8809e683
Commit
8809e683
authored
4 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
WIP: Update more errors
parent
c99d9bc4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_affiliation.py
+43
-40
43 additions, 40 deletions
tests/test_affiliation.py
tests/test_issues_server.py
+2
-2
2 additions, 2 deletions
tests/test_issues_server.py
with
45 additions
and
42 deletions
tests/test_affiliation.py
+
43
−
40
View file @
8809e683
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
import
caosdb
as
db
import
caosdb
as
db
import
os
import
os
from
nose.tools
import
nottest
,
assert_true
,
assert_raises
,
assert_equal
,
with_setup
,
assert_is_not_none
# @UnresolvedImport
from
nose.tools
import
nottest
,
assert_true
,
assert_raises
,
assert_equal
,
with_setup
,
assert_is_not_none
# @UnresolvedImport
from
pytest
import
raises
def
setup_module
():
def
setup_module
():
...
@@ -86,31 +87,33 @@ def test_rec_rt_is_instantiation():
...
@@ -86,31 +87,33 @@ def test_rec_rt_is_instantiation():
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
def
test_rec_prop_is_invalid
():
def
test_rec_prop_is_invalid
():
with
assert_
raises
(
db
.
Entity
Error
)
as
cm
:
with
raises
(
db
.
Transaction
Error
)
as
cm
:
db
.
Record
(
name
=
"
TestRecordChild
"
).
add_parent
(
name
=
prop_name
).
insert
()
db
.
Record
(
name
=
"
TestRecordChild
"
).
add_parent
(
name
=
prop_name
).
insert
()
assert_equal
(
assert
cm
.
value
.
has_error
(
db
.
UnqualifiedParentsError
)
cm
.
exception
.
get_errors
()[
0
].
msg
,
# TransactionError with UnqualifiedParentsError with EntityError
"
Affiliation is not defined for this child-parent constellation.
"
)
# caused by wrong affiliation
ee
=
cm
.
value
.
get_errors
()[
0
].
get_errors
()[
0
]
assert
ee
.
msg
==
"
Affiliation is not defined for this child-parent constellation.
"
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
def
test_rec_file_is_invalid
():
def
test_rec_file_is_invalid
():
with
assert_
raises
(
db
.
Entity
Error
)
as
cm
:
with
raises
(
db
.
Transaction
Error
)
as
cm
:
db
.
Record
(
name
=
"
TestRecordChild
"
).
add_parent
(
name
=
file_name
).
insert
()
db
.
Record
(
name
=
"
TestRecordChild
"
).
add_parent
(
name
=
file_name
).
insert
()
assert
_equal
(
assert
cm
.
value
.
has_error
(
db
.
UnqualifiedParentsError
)
cm
.
exception
.
get_errors
()[
0
]
.
msg
,
ee
=
cm
.
value
.
get_errors
()[
0
]
.
get_errors
()[
0
]
"
Affiliation is not defined for this child-parent constellation.
"
)
assert
ee
.
msg
==
"
Affiliation is not defined for this child-parent constellation.
"
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
def
test_rt_rec_is_invalid
():
def
test_rt_rec_is_invalid
():
with
assert_
raises
(
db
.
Entity
Error
)
as
cm
:
with
raises
(
db
.
Transaction
Error
)
as
cm
:
db
.
RecordType
(
db
.
RecordType
(
name
=
"
TestRecordTypeChild
"
).
add_parent
(
name
=
"
TestRecordTypeChild
"
).
add_parent
(
name
=
rec_name
).
insert
()
name
=
rec_name
).
insert
()
assert
_equal
(
assert
cm
.
value
.
has_error
(
db
.
UnqualifiedParentsError
)
cm
.
exception
.
get_errors
()[
0
]
.
msg
,
ee
=
cm
.
value
.
get_errors
()[
0
]
.
get_errors
()[
0
]
"
Affiliation is not defined for this child-parent constellation.
"
)
assert
ee
.
msg
==
"
Affiliation is not defined for this child-parent constellation.
"
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
...
@@ -122,48 +125,48 @@ def test_rt_rt_is_subtyping():
...
@@ -122,48 +125,48 @@ def test_rt_rt_is_subtyping():
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
def
test_rt_prop_is_invalid
():
def
test_rt_prop_is_invalid
():
with
assert_
raises
(
db
.
Entity
Error
)
as
cm
:
with
raises
(
db
.
Transaction
Error
)
as
cm
:
db
.
RecordType
(
db
.
RecordType
(
name
=
"
TestRecordTypeChild
"
).
add_parent
(
name
=
"
TestRecordTypeChild
"
).
add_parent
(
name
=
prop_name
).
insert
()
name
=
prop_name
).
insert
()
assert
_equal
(
assert
cm
.
value
.
has_error
(
db
.
UnqualifiedParentsError
)
cm
.
exception
.
get_errors
()[
0
]
.
msg
,
ee
=
cm
.
value
.
get_errors
()[
0
]
.
get_errors
()[
0
]
"
Affiliation is not defined for this child-parent constellation.
"
)
assert
ee
.
msg
==
"
Affiliation is not defined for this child-parent constellation.
"
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
def
test_rt_file_is_invalid
():
def
test_rt_file_is_invalid
():
with
assert_
raises
(
db
.
Entity
Error
)
as
cm
:
with
raises
(
db
.
Transaction
Error
)
as
cm
:
db
.
RecordType
(
db
.
RecordType
(
name
=
"
TestRecordTypeChild
"
).
add_parent
(
name
=
"
TestRecordTypeChild
"
).
add_parent
(
name
=
file_name
).
insert
()
name
=
file_name
).
insert
()
assert
_equal
(
assert
cm
.
value
.
has_error
(
db
.
UnqualifiedParentsError
)
cm
.
exception
.
get_errors
()[
0
]
.
msg
,
ee
=
cm
.
value
.
get_errors
()[
0
]
.
get_errors
()[
0
]
"
Affiliation is not defined for this child-parent constellation.
"
)
assert
ee
.
msg
==
"
Affiliation is not defined for this child-parent constellation.
"
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
def
test_prop_rec_is_invalid
():
def
test_prop_rec_is_invalid
():
with
assert_
raises
(
db
.
Entity
Error
)
as
cm
:
with
raises
(
db
.
Transaction
Error
)
as
cm
:
db
.
Property
(
db
.
Property
(
name
=
"
TestPropertyChild
"
,
name
=
"
TestPropertyChild
"
,
datatype
=
db
.
TEXT
).
add_parent
(
datatype
=
db
.
TEXT
).
add_parent
(
name
=
rec_name
).
insert
()
name
=
rec_name
).
insert
()
assert
_equal
(
assert
cm
.
value
.
has_error
(
db
.
UnqualifiedParentsError
)
cm
.
exception
.
get_errors
()[
0
]
.
msg
,
ee
=
cm
.
value
.
get_errors
()[
0
]
.
get_errors
()[
0
]
"
Affiliation is not defined for this child-parent constellation.
"
)
assert
ee
.
msg
==
"
Affiliation is not defined for this child-parent constellation.
"
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
def
test_prop_rt_is_invalid
():
def
test_prop_rt_is_invalid
():
with
assert_
raises
(
db
.
Entity
Error
)
as
cm
:
with
raises
(
db
.
Transaction
Error
)
as
cm
:
db
.
Property
(
db
.
Property
(
name
=
"
TestPropertyChild
"
,
name
=
"
TestPropertyChild
"
,
datatype
=
db
.
TEXT
).
add_parent
(
datatype
=
db
.
TEXT
).
add_parent
(
name
=
recty_name
).
insert
()
name
=
recty_name
).
insert
()
assert
_equal
(
assert
cm
.
value
.
has_error
(
db
.
UnqualifiedParentsError
)
cm
.
exception
.
get_errors
()[
0
]
.
msg
,
ee
=
cm
.
value
.
get_errors
()[
0
]
.
get_errors
()[
0
]
"
Affiliation is not defined for this child-parent constellation.
"
)
assert
ee
.
msg
==
"
Affiliation is not defined for this child-parent constellation.
"
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
...
@@ -177,14 +180,14 @@ def test_prop_prop_is_subtyping():
...
@@ -177,14 +180,14 @@ def test_prop_prop_is_subtyping():
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
def
test_prop_file_is_invalid
():
def
test_prop_file_is_invalid
():
with
assert_
raises
(
db
.
Entity
Error
)
as
cm
:
with
raises
(
db
.
Transaction
Error
)
as
cm
:
db
.
Property
(
db
.
Property
(
name
=
"
TestPropertyChild
"
,
name
=
"
TestPropertyChild
"
,
datatype
=
db
.
TEXT
).
add_parent
(
datatype
=
db
.
TEXT
).
add_parent
(
name
=
file_name
).
insert
()
name
=
file_name
).
insert
()
assert
_equal
(
assert
cm
.
value
.
has_error
(
db
.
UnqualifiedParentsError
)
cm
.
exception
.
get_errors
()[
0
]
.
msg
,
ee
=
cm
.
value
.
get_errors
()[
0
]
.
get_errors
()[
0
]
"
Affiliation is not defined for this child-parent constellation.
"
)
assert
ee
.
msg
==
"
Affiliation is not defined for this child-parent constellation.
"
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
...
@@ -209,28 +212,28 @@ def test_file_rt_is_instantiation():
...
@@ -209,28 +212,28 @@ def test_file_rt_is_instantiation():
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
def
test_file_prop_is_invalid
():
def
test_file_prop_is_invalid
():
with
assert_
raises
(
db
.
Entity
Error
)
as
cm
:
with
raises
(
db
.
Transaction
Error
)
as
cm
:
db
.
File
(
db
.
File
(
name
=
"
TestFileChild
"
,
name
=
"
TestFileChild
"
,
file
=
file_path
,
file
=
file_path
,
path
=
"
testfilechild.dat
"
).
add_parent
(
path
=
"
testfilechild.dat
"
).
add_parent
(
name
=
prop_name
).
insert
()
name
=
prop_name
).
insert
()
assert
_equal
(
assert
cm
.
value
.
has_error
(
db
.
UnqualifiedParentsError
)
cm
.
exception
.
get_errors
()[
0
]
.
msg
,
ee
=
cm
.
value
.
get_errors
()[
0
]
.
get_errors
()[
0
]
"
Affiliation is not defined for this child-parent constellation.
"
)
assert
ee
.
msg
==
"
Affiliation is not defined for this child-parent constellation.
"
@with_setup
(
setup
,
teardown
)
@with_setup
(
setup
,
teardown
)
def
test_file_file_is_invalid
():
def
test_file_file_is_invalid
():
with
assert_
raises
(
db
.
Entity
Error
)
as
cm
:
with
raises
(
db
.
Transaction
Error
)
as
cm
:
db
.
File
(
db
.
File
(
name
=
"
TestFileChild
"
,
name
=
"
TestFileChild
"
,
file
=
file_path
,
file
=
file_path
,
path
=
"
testfilechild.dat
"
).
add_parent
(
path
=
"
testfilechild.dat
"
).
add_parent
(
name
=
file_name
).
insert
()
name
=
file_name
).
insert
()
assert
_equal
(
assert
cm
.
value
.
has_error
(
db
.
UnqualifiedParentsError
)
cm
.
exception
.
get_errors
()[
0
]
.
msg
,
ee
=
cm
.
value
.
get_errors
()[
0
]
.
get_errors
()[
0
]
"
Affiliation is not defined for this child-parent constellation.
"
)
assert
ee
.
msg
==
"
Affiliation is not defined for this child-parent constellation.
"
@nottest
@nottest
...
...
This diff is collapsed.
Click to expand it.
tests/test_issues_server.py
+
2
−
2
View file @
8809e683
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
"""
Tests for issues on gitlab.com, project caosdb-server.
"""
"""
Tests for issues on gitlab.com, project caosdb-server.
"""
import
caosdb
as
db
import
caosdb
as
db
from
caosdb.exceptions
import
Entity
Error
from
caosdb.exceptions
import
Transaction
Error
import
pytest
import
pytest
...
@@ -69,7 +69,7 @@ def test_issue_62():
...
@@ -69,7 +69,7 @@ def test_issue_62():
assert
prop
.
datatype
==
rtb
.
name
# fails; datatype not updated
assert
prop
.
datatype
==
rtb
.
name
# fails; datatype not updated
# Can't use Test_RTA as datatype anymore
# Can't use Test_RTA as datatype anymore
prop2
=
db
.
Property
(
name
=
"
Test_Prop2
"
,
datatype
=
"
Test_RTA
"
)
prop2
=
db
.
Property
(
name
=
"
Test_Prop2
"
,
datatype
=
"
Test_RTA
"
)
with
pytest
.
raises
(
Entity
Error
):
with
pytest
.
raises
(
Transaction
Error
):
prop2
.
insert
()
prop2
.
insert
()
...
...
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