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
a9ed38a7
Unverified
Commit
a9ed38a7
authored
4 years ago
by
Daniel
Browse files
Options
Downloads
Patches
Plain Diff
STY: Style fix.
parent
2afced61
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
tests/test_list.py
+97
-100
97 additions, 100 deletions
tests/test_list.py
with
97 additions
and
100 deletions
tests/test_list.py
+
97
−
100
View file @
a9ed38a7
...
...
@@ -27,9 +27,9 @@
"""
import
os
import
caosdb
as
db
from
pytest
import
mark
from
nose.tools
import
nottest
,
assert_true
,
assert_raises
,
assert_equal
from
caosdb.exceptions
import
TransactionError
from
nose.tools
import
nottest
,
assert_true
,
assert_raises
,
assert_equal
from
pytest
import
mark
def
setup
():
...
...
@@ -58,23 +58,23 @@ def test_list_of_files():
recty
=
db
.
RecordType
(
name
=
"
TestRT
"
).
insert
()
rec
=
db
.
Record
(
name
=
"
TestRecOk
"
).
add_parent
(
recty
).
add_property
(
name
=
"
TestListProperty
"
,
datatype
=
db
.
LIST
(
db
.
FILE
),
value
=
[
file_
.
id
]).
insert
()
assert_true
(
rec
.
is_valid
())
with
assert_raises
(
TransactionError
)
as
cm
:
db
.
Record
(
name
=
"
TestRecNotOk
"
).
add_parent
(
recty
).
add_property
(
name
=
"
TestListProperty
"
,
datatype
=
db
.
LIST
(
db
.
FILE
),
value
=
[
p
.
id
]).
insert
()
file_
.
id
]).
insert
()
assert_true
(
rec
.
is_valid
())
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
Record
(
name
=
"
TestRecNotOk
"
).
add_parent
(
recty
).
add_property
(
name
=
"
TestListProperty
"
,
datatype
=
db
.
LIST
(
db
.
FILE
),
value
=
[
p
.
id
]).
insert
()
assert_equal
(
cm
.
exception
.
errors
[
0
].
msg
,
tr_err
.
exception
.
errors
[
0
].
msg
,
"
Reference not qualified. The value of this Reference Property is to be a child of its data type.
"
)
...
...
@@ -106,7 +106,7 @@ def test_rt_property_without_value():
rt
=
db
.
RecordType
(
name
=
"
TestRT
"
).
add_property
(
name
=
"
TestListProperty
"
).
insert
()
name
=
"
TestListProperty
"
).
insert
()
assert_true
(
rt
.
is_valid
())
assert_equal
(
...
...
@@ -130,9 +130,9 @@ def test_concrete_property_with_single_value():
rt
=
db
.
RecordType
(
name
=
"
TestRT
"
).
add_property
(
name
=
"
TestListProperty
"
,
value
=
[
1
]).
insert
(
sync
=
False
)
name
=
"
TestListProperty
"
,
value
=
[
1
]).
insert
(
sync
=
False
)
assert_equal
(
"
[1]
"
,
str
(
rt
.
get_property
(
"
TestListProperty
"
).
value
))
assert_equal
([
1
],
rt
.
get_property
(
"
TestListProperty
"
).
value
)
assert_true
(
rt
.
is_valid
())
...
...
@@ -167,8 +167,8 @@ def test_query_concrete_property_with_single_value():
rt
=
db
.
RecordType
(
name
=
"
TestRT
"
).
add_property
(
name
=
"
TestListProperty
"
,
value
=
[
1337
]).
insert
()
name
=
"
TestListProperty
"
,
value
=
[
1337
]).
insert
()
assert_true
(
rt
.
is_valid
())
assert_equal
(
...
...
@@ -187,8 +187,8 @@ def test_query_concrete_property_with_more_values():
rt
=
db
.
RecordType
(
name
=
"
TestRT
"
).
add_property
(
name
=
"
TestListProperty
"
,
value
=
[
1337
,
2
,
3
]).
insert
()
name
=
"
TestListProperty
"
,
value
=
[
1337
,
2
,
3
]).
insert
()
assert_true
(
rt
.
is_valid
())
assert_equal
(
...
...
@@ -205,36 +205,36 @@ def test_error_on_wrong_value():
db
.
INTEGER
)).
insert
()
assert_true
(
p
.
is_valid
())
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
RecordType
(
name
=
"
TestRT
"
).
add_property
(
name
=
"
TestListProperty
"
,
value
=
[
"
this is not an int
"
]).
insert
()
assert_equal
(
cm
.
exception
.
msg
,
"
Entity has unqualified properties.
"
)
name
=
"
TestListProperty
"
,
value
=
[
"
this is not an int
"
]).
insert
()
assert_equal
(
tr_err
.
exception
.
msg
,
"
Entity has unqualified properties.
"
)
assert_equal
(
cm
.
exception
.
get_errors
()[
0
].
msg
,
tr_err
.
exception
.
get_errors
()[
0
].
msg
,
"
Cannot parse value to integer.
"
)
def
test_data_type_with_non_existing_ref1
():
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
Property
(
name
=
"
TestListProperty
"
,
datatype
=
db
.
LIST
(
"
non_existing
"
)).
insert
()
assert_equal
(
cm
.
exception
.
msg
,
"
Unknown datatype.
"
)
assert_equal
(
tr_err
.
exception
.
msg
,
"
Unknown datatype.
"
)
def
test_data_type_with_non_existing_ref2
():
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
Property
(
name
=
"
TestListProperty
"
,
datatype
=
db
.
LIST
(
234233234
)).
insert
()
assert_equal
(
cm
.
exception
.
msg
,
"
Unknown datatype.
"
)
assert_equal
(
tr_err
.
exception
.
msg
,
"
Unknown datatype.
"
)
def
test_data_type_with_non_existing_ref3
():
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
Property
(
name
=
"
TestListProperty
"
,
datatype
=
db
.
LIST
(
-
2341
)).
insert
()
assert_equal
(
cm
.
exception
.
msg
,
"
Unknown datatype.
"
)
assert_equal
(
tr_err
.
exception
.
msg
,
"
Unknown datatype.
"
)
def
test_data_type_with_existing_ref1
():
...
...
@@ -283,7 +283,7 @@ def test_rt_ref_property_without_value():
rt2
=
db
.
RecordType
(
name
=
"
TestRT2
"
).
add_property
(
name
=
"
TestListProperty
"
).
insert
()
name
=
"
TestListProperty
"
).
insert
()
assert_true
(
rt2
.
is_valid
())
assert_equal
(
rt2
.
get_property
(
"
TestListProperty
"
).
datatype
,
...
...
@@ -303,7 +303,7 @@ def test_datatype_inheritance1():
db
.
Property
(
name
=
"
TestListProperty
"
,
datatype
=
db
.
LIST
(
rt
.
name
)).
insert
()
p2
=
db
.
Property
(
name
=
"
TestListProperty2
"
).
add_parent
(
name
=
"
TestListProperty
"
).
insert
()
name
=
"
TestListProperty
"
).
insert
()
assert_equal
(
p2
.
datatype
,
db
.
LIST
(
rt
.
name
))
assert_equal
(
...
...
@@ -323,7 +323,7 @@ def test_datatype_inheritance2():
name
=
"
TestListProperty2
"
,
datatype
=
db
.
LIST
(
rt2
.
name
)).
add_parent
(
name
=
"
TestListProperty
"
).
insert
()
name
=
"
TestListProperty
"
).
insert
()
assert_equal
(
p2
.
datatype
,
db
.
LIST
(
rt2
.
name
))
assert_equal
(
...
...
@@ -343,7 +343,7 @@ def test_datatype_inheritance3():
name
=
"
TestListProperty2
"
,
datatype
=
db
.
LIST
(
rt2
.
name
)).
add_parent
(
name
=
"
TestListProperty
"
).
insert
()
name
=
"
TestListProperty
"
).
insert
()
assert_equal
(
p2
.
datatype
,
db
.
LIST
(
rt2
.
name
))
assert_equal
(
...
...
@@ -361,8 +361,8 @@ def test_single_ref_value():
rt2
=
db
.
RecordType
(
name
=
"
TestRT2
"
).
add_property
(
name
=
"
TestProp
"
,
value
=
[
rec
]).
insert
()
name
=
"
TestProp
"
,
value
=
[
rec
]).
insert
()
assert_true
(
rt2
.
is_valid
())
...
...
@@ -373,13 +373,13 @@ def test_single_ref_value_scope_error():
rt2
=
db
.
RecordType
(
name
=
"
TestRT2
"
).
insert
()
db
.
Property
(
name
=
"
TestProp
"
,
datatype
=
db
.
LIST
(
rt2
)).
insert
()
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
RecordType
(
name
=
"
TestRT3
"
).
add_property
(
name
=
"
TestProp
"
,
value
=
[
rec
]).
insert
()
name
=
"
TestProp
"
,
value
=
[
rec
]).
insert
()
assert_equal
(
cm
.
exception
.
get_errors
()[
0
].
msg
,
tr_err
.
exception
.
get_errors
()[
0
].
msg
,
"
Reference not qualified. The value of this Reference Property is to be a child of its data type.
"
)
...
...
@@ -387,29 +387,29 @@ def test_error_single_non_existing_ref_value():
rt
=
db
.
RecordType
(
name
=
"
TestRT
"
).
insert
()
db
.
Property
(
name
=
"
TestProp
"
,
datatype
=
db
.
LIST
(
rt
)).
insert
()
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
RecordType
(
name
=
"
TestRT2
"
).
add_property
(
name
=
"
TestProp
"
,
value
=
[
"
non_existing
"
]).
insert
()
name
=
"
TestProp
"
,
value
=
[
"
non_existing
"
]).
insert
()
assert_equal
(
cm
.
exception
.
get_errors
()[
0
].
msg
,
tr_err
.
exception
.
get_errors
()[
0
].
msg
,
"
Referenced entity does not exist.
"
)
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
RecordType
(
name
=
"
TestRT2
"
).
add_property
(
name
=
"
TestProp
"
,
value
=
[
213425234234
]).
insert
()
name
=
"
TestProp
"
,
value
=
[
213425234234
]).
insert
()
assert_equal
(
cm
.
exception
.
get_errors
()[
0
].
msg
,
tr_err
.
exception
.
get_errors
()[
0
].
msg
,
"
Referenced entity does not exist.
"
)
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
RecordType
(
name
=
"
TestRT2
"
).
add_property
(
name
=
"
TestProp
"
,
value
=
[
-
1234
]).
insert
()
assert_equal
(
cm
.
exception
.
get_errors
()[
0
].
msg
,
tr_err
.
exception
.
get_errors
()[
0
].
msg
,
"
Referenced entity does not exist.
"
)
...
...
@@ -419,37 +419,37 @@ def test_error_multi_non_existing_ref_value():
db
.
Record
(
name
=
"
TestRec2
"
).
add_parent
(
name
=
"
TestRT
"
).
insert
()
db
.
Property
(
name
=
"
TestProp
"
,
datatype
=
db
.
LIST
(
rt
)).
insert
()
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
RecordType
(
name
=
"
TestRT2
"
).
add_property
(
name
=
"
TestProp
"
,
value
=
[
"
TestRec1
"
,
"
non_existing
"
,
"
TestRec2
"
]).
insert
()
name
=
"
TestProp
"
,
value
=
[
"
TestRec1
"
,
"
non_existing
"
,
"
TestRec2
"
]).
insert
()
assert_equal
(
cm
.
exception
.
get_errors
()[
0
].
msg
,
tr_err
.
exception
.
get_errors
()[
0
].
msg
,
"
Referenced entity does not exist.
"
)
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
RecordType
(
name
=
"
TestRT2
"
).
add_property
(
name
=
"
TestProp
"
,
value
=
[
213425234234
,
"
TestRec2
"
,
"
TestRec1
"
]).
insert
()
value
=
[
213425234234
,
"
TestRec2
"
,
"
TestRec1
"
]).
insert
()
assert_equal
(
cm
.
exception
.
get_errors
()[
0
].
msg
,
tr_err
.
exception
.
get_errors
()[
0
].
msg
,
"
Referenced entity does not exist.
"
)
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
RecordType
(
name
=
"
TestRT2
"
).
add_property
(
name
=
"
TestProp
"
,
value
=
[
"
TestRec1
"
,
"
TestRec2
"
,
-
1234
]).
insert
()
name
=
"
TestProp
"
,
value
=
[
"
TestRec1
"
,
"
TestRec2
"
,
-
1234
]).
insert
()
assert_equal
(
cm
.
exception
.
get_errors
()[
0
].
msg
,
tr_err
.
exception
.
get_errors
()[
0
].
msg
,
"
Referenced entity does not exist.
"
)
...
...
@@ -462,16 +462,16 @@ def test_multi_ref_value_scope_error():
db
.
Record
(
name
=
"
TestRec2
"
).
add_parent
(
name
=
"
TestRT2
"
).
insert
()
db
.
Property
(
name
=
"
TestProp
"
,
datatype
=
db
.
LIST
(
rt2
)).
insert
()
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
RecordType
(
name
=
"
TestRT3
"
).
add_property
(
name
=
"
TestProp
"
,
value
=
[
rec
,
"
TestRec1
"
,
"
TestRec2
"
]).
insert
()
name
=
"
TestProp
"
,
value
=
[
rec
,
"
TestRec1
"
,
"
TestRec2
"
]).
insert
()
assert_equal
(
cm
.
exception
.
get_errors
()[
0
].
msg
,
tr_err
.
exception
.
get_errors
()[
0
].
msg
,
"
Reference not qualified. The value of this Reference Property is to be a child of its data type.
"
)
...
...
@@ -484,8 +484,8 @@ def test_multi_ref_value():
rt2
=
db
.
RecordType
(
name
=
"
TestRT2
"
).
add_property
(
name
=
"
TestProp
"
,
value
=
[
rec
,
rec2
.
id
,
"
TestRec2
"
]).
insert
()
name
=
"
TestProp
"
,
value
=
[
rec
,
rec2
.
id
,
"
TestRec2
"
]).
insert
()
assert_true
(
rt2
.
is_valid
())
assert_equal
(
...
...
@@ -513,13 +513,13 @@ def test_multi_ref_with_doublets():
db
.
Property
(
name
=
"
TestProp
"
,
datatype
=
db
.
LIST
(
rt
)).
insert
()
rt2
=
db
.
RecordType
(
name
=
"
TestRT2
"
).
add_property
(
name
=
"
TestProp
"
,
value
=
[
rec1
,
rec2
,
rec3
,
rec2
,
rec1
]).
insert
()
name
=
"
TestProp
"
,
value
=
[
rec1
,
rec2
,
rec3
,
rec2
,
rec1
]).
insert
()
assert_true
(
rt2
.
is_valid
())
assert_equal
(
len
(
rt2
.
get_property
(
"
TestProp
"
).
value
),
5
)
...
...
@@ -547,11 +547,11 @@ def test_multi_ref_with_null():
db
.
Property
(
name
=
"
TestProp
"
,
datatype
=
db
.
LIST
(
rt
)).
insert
()
rt2
=
db
.
RecordType
(
name
=
"
TestRT2
"
).
add_property
(
name
=
"
TestProp
"
,
value
=
[
rec1
,
rec2
,
None
]).
insert
()
name
=
"
TestProp
"
,
value
=
[
rec1
,
rec2
,
None
]).
insert
()
assert_true
(
rt2
.
is_valid
())
assert_equal
(
len
(
rt2
.
get_property
(
"
TestProp
"
).
value
),
3
)
assert_equal
(
rt2
.
get_property
(
"
TestProp
"
).
value
[
0
],
rec1
.
id
)
...
...
@@ -632,8 +632,8 @@ def test_list_of_references():
rt1
=
db
.
RecordType
(
name
=
"
Test_RT1
"
).
insert
()
rt2
=
db
.
RecordType
(
name
=
"
Test_RT2
"
).
add_property
(
name
=
"
Test_RT1
"
,
datatype
=
db
.
LIST
(
"
Test_RT1
"
)).
insert
()
name
=
"
Test_RT1
"
,
datatype
=
db
.
LIST
(
"
Test_RT1
"
)).
insert
()
p
=
rt2
.
get_properties
()[
0
]
assert_equal
(
p
.
id
,
rt1
.
id
)
assert_equal
(
p
.
name
,
rt1
.
name
)
...
...
@@ -647,13 +647,13 @@ def test_list_of_references():
rt1rec1
=
db
.
Record
(
name
=
"
Test_RT1_Rec1
"
).
add_parent
(
"
Test_RT1
"
).
insert
()
assert_true
(
rt1rec1
.
is_valid
())
with
assert_raises
(
TransactionError
)
as
cm
:
with
assert_raises
(
TransactionError
)
as
tr_err
:
db
.
Record
(
name
=
"
Test_RT2_Rec
"
).
add_parent
(
"
Test_RT2
"
).
add_property
(
name
=
"
Test_RT1
"
,
value
=
[
rt1rec1
]).
insert
()
name
=
"
Test_RT1
"
,
value
=
[
rt1rec1
]).
insert
()
assert_equal
(
cm
.
exception
.
get_errors
()[
0
].
msg
,
tr_err
.
exception
.
get_errors
()[
0
].
msg
,
'
This datatype does not accept collections of values (e.g. Lists).
'
)
rt2rec
=
db
.
Record
(
name
=
"
Test_RT2_Rec
"
).
add_parent
(
"
Test_RT2
"
).
add_property
(
name
=
"
Test_RT1
"
,
datatype
=
db
.
LIST
(
"
Test_RT1
"
),
value
=
[
rt1rec1
]).
insert
()
...
...
@@ -673,6 +673,3 @@ def test_list_in_sub_property():
rec2
.
insert
()
rec2
.
delete
()
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