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
fad9c43c
Commit
fad9c43c
authored
1 year ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
TST: Extend unit tests
parent
f4edcc84
No related branches found
No related tags found
3 merge requests
!159
Release 0.16.o
,
!155
Review filter lists and compare_entities
,
!137
Allow property and parent lists to be filtered.
Pipeline
#50074
failed
1 year ago
Stage: code_style
Stage: linting
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_entity.py
+46
-3
46 additions, 3 deletions
unittests/test_entity.py
with
46 additions
and
3 deletions
unittests/test_entity.py
+
46
−
3
View file @
fad9c43c
...
...
@@ -25,6 +25,7 @@
import
os
# pylint: disable=missing-docstring
import
unittest
from
pytest
import
raises
import
linkahead
from
linkahead
import
(
INTEGER
,
Entity
,
Property
,
Record
,
RecordType
,
...
...
@@ -105,20 +106,62 @@ def test_parent_list():
pl
=
linkahead
.
common
.
models
.
ParentList
([
p1
])
assert
p1
in
pl
assert
RecordType
(
name
=
"
A
"
)
in
pl
assert
not
RecordType
(
id
=
101
)
in
pl
assert
pl
.
index
(
RecordType
(
name
=
"
A
"
))
==
0
assert
RecordType
(
id
=
101
)
not
in
pl
pl
.
append
(
RecordType
(
id
=
101
))
assert
RecordType
(
name
=
"
A
"
)
in
pl
assert
RecordType
(
id
=
101
)
in
pl
assert
not
RecordType
(
id
=
102
)
in
pl
assert
len
(
pl
)
==
2
assert
pl
.
index
(
RecordType
(
id
=
101
))
assert
RecordType
(
id
=
102
)
not
in
pl
pl
.
append
(
RecordType
(
id
=
103
,
name
=
'
B
'
))
assert
RecordType
(
name
=
"
A
"
)
in
pl
assert
RecordType
(
name
=
"
B
"
)
in
pl
assert
RecordType
(
id
=
101
)
in
pl
assert
RecordType
(
id
=
103
)
in
pl
assert
not
RecordType
(
id
=
105
,
name
=
"
B
"
)
in
pl
assert
len
(
pl
)
==
3
assert
pl
.
index
(
RecordType
(
id
=
103
,
name
=
'
B
'
))
==
2
assert
pl
.
index
(
RecordType
(
id
=
103
))
==
2
assert
pl
.
index
(
RecordType
(
name
=
'
B
'
))
==
2
assert
RecordType
(
id
=
105
,
name
=
"
B
"
)
not
in
pl
# test removal
# remove by id only, even though element in parent list has name and id
pl
.
remove
(
RecordType
(
id
=
103
))
assert
len
(
pl
)
==
2
assert
RecordType
(
name
=
'
B
'
)
not
in
pl
assert
RecordType
(
id
=
103
)
not
in
pl
# Same for removal by name
pl
.
append
(
RecordType
(
id
=
103
,
name
=
'
B
'
))
assert
len
(
pl
)
==
3
pl
.
remove
(
RecordType
(
name
=
'
B
'
))
assert
len
(
pl
)
==
2
assert
RecordType
(
name
=
'
B
'
)
not
in
pl
assert
RecordType
(
id
=
103
)
not
in
pl
# And an error if the element is wrongly specified
pl
.
append
(
RecordType
(
id
=
103
,
name
=
'
B
'
))
assert
len
(
pl
)
==
3
with
raises
(
ValueError
)
as
ve
:
pl
.
remove
(
RecordType
(
id
=
105
,
name
=
'
B
'
))
assert
"
not in list
"
in
str
(
ve
.
value
)
assert
len
(
pl
)
==
3
with
raises
(
ValueError
)
as
ve
:
pl
.
remove
(
RecordType
(
id
=
103
,
name
=
'
C
'
))
assert
"
not in list
"
in
str
(
ve
.
value
)
assert
len
(
pl
)
==
3
# TODO also check other built-in list functions: insert, pop, clear, count
# TODO also check pl1 == pl2
# TODO what is with RecordType(name='A', id=100) in pl? I.e., fitting name,
# but id of corresponding element in pl is None. Same of course for
# RecordType(name='C', id=101) in pl, i.e. fitting id, but name of element
# in pl is None.
# TODO what is with the ambiguous RecordType(name='A', id=101) in pl?
def
test_property_list
():
# TODO: Resolve parent-list TODOs, the transfer to here.
# TODO: What other considerations have to be done with properties?
p1
=
Property
(
name
=
"
A
"
)
pl
=
linkahead
.
common
.
models
.
PropertyList
()
pl
.
append
(
p1
)
...
...
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