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
5cbc9efb
Commit
5cbc9efb
authored
6 months ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
TST: add test case for compare_entities
parent
133c0e36
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!159
Release 0.16.o
,
!157
compare entities and parent/property lists
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/linkahead/apiutils.py
+2
-1
2 additions, 1 deletion
src/linkahead/apiutils.py
unittests/test_apiutils.py
+9
-2
9 additions, 2 deletions
unittests/test_apiutils.py
with
11 additions
and
3 deletions
src/linkahead/apiutils.py
+
2
−
1
View file @
5cbc9efb
...
...
@@ -207,7 +207,8 @@ def compare_entities(entity0: Optional[Entity] = None,
If any of these characteristics differ for a property, the respective
string (datatype, importance, value) is added as a key to the dict of the
property with its value being the characteristics value,
e.g. {
"
prop
"
: {
"
value
"
: 6,
'
importance
'
:
'
SUGGESTED
'
}}.
e.g. {
"
prop
"
: {
"
value
"
: 6,
'
importance
'
:
'
SUGGESTED
'
}}. Except: None as
value is not added to the dict.
If a property is of type LIST, the comparison is order-sensitive.
Comparison of multi-properties is not yet supported, so should either
...
...
This diff is collapsed.
Click to expand it.
unittests/test_apiutils.py
+
9
−
2
View file @
5cbc9efb
...
...
@@ -113,13 +113,15 @@ def test_compare_entities():
r2
.
add_property
(
"
tester
"
,
)
r1
.
add_property
(
"
tests_234234
"
,
value
=
45
)
r2
.
add_property
(
"
tests_TT
"
,
value
=
45
)
r1
.
add_property
(
"
datatype
"
,
value
=
45
,
datatype
=
db
.
INTEGER
)
r2
.
add_property
(
"
datatype
"
,
value
=
45
)
diff_r1
,
diff_r2
=
compare_entities
(
r1
,
r2
)
assert
len
(
diff_r1
[
"
parents
"
])
==
1
assert
len
(
diff_r2
[
"
parents
"
])
==
0
assert
len
(
diff_r1
[
"
properties
"
])
==
4
assert
len
(
diff_r2
[
"
properties
"
])
==
4
assert
len
(
diff_r1
[
"
properties
"
])
==
5
assert
len
(
diff_r2
[
"
properties
"
])
==
5
assert
"
test
"
not
in
diff_r1
[
"
properties
"
]
assert
"
test
"
not
in
diff_r2
[
"
properties
"
]
...
...
@@ -136,6 +138,11 @@ def test_compare_entities():
assert
"
tests_234234
"
in
diff_r1
[
"
properties
"
]
assert
"
tests_TT
"
in
diff_r2
[
"
properties
"
]
assert
"
datatype
"
in
diff_r1
[
"
properties
"
]
assert
"
datatype
"
in
diff_r1
[
"
properties
"
][
"
datatype
"
]
assert
"
datatype
"
in
diff_r2
[
"
properties
"
]
assert
"
datatype
"
not
in
diff_r2
[
"
properties
"
][
"
datatype
"
]
# test compare units of properties
r1
=
db
.
Record
()
r2
=
db
.
Record
()
...
...
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