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
e544bd65
Commit
e544bd65
authored
3 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
TST: added tests for compare entities
parent
b0516bd6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!36
RELEASE: 0.6.1
,
!35
F fix compare entities branch2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_apiutils.py
+31
-1
31 additions, 1 deletion
unittests/test_apiutils.py
with
31 additions
and
1 deletion
unittests/test_apiutils.py
+
31
−
1
View file @
e544bd65
...
...
@@ -29,7 +29,7 @@
import
caosdb
as
db
import
pickle
import
tempfile
from
caosdb.apiutils
import
apply_to_ids
,
create_id_query
,
resolve_reference
from
caosdb.apiutils
import
apply_to_ids
,
create_id_query
,
resolve_reference
,
compare_entities
import
caosdb.apiutils
from
.test_property
import
testrecord
...
...
@@ -102,3 +102,33 @@ def test_resolve_reference():
# restore retrive_entity_with_id
caosdb
.
apiutils
.
retrieve_entity_with_id
=
original_retrieve_entity_with_id
def
test_compare_entities
():
r1
=
db
.
Record
()
r2
=
db
.
Record
()
r1
.
add_parent
(
"
bla
"
)
r2
.
add_parent
(
"
bla
"
)
r1
.
add_parent
(
"
lopp
"
)
r1
.
add_property
(
"
test
"
,
value
=
2
)
r2
.
add_property
(
"
test
"
,
value
=
2
)
r1
.
add_property
(
"
tests
"
,
value
=
3
)
r2
.
add_property
(
"
tests
"
,
value
=
45
)
r1
.
add_property
(
"
tests_234234
"
,
value
=
45
)
r2
.
add_property
(
"
tests_TT
"
,
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
"
])
==
2
assert
len
(
diff_r2
[
"
properties
"
])
==
2
assert
"
test
"
not
in
diff_r1
[
"
properties
"
]
assert
"
test
"
not
in
diff_r2
[
"
properties
"
]
assert
"
tests
"
in
diff_r1
[
"
properties
"
]
assert
"
tests
"
in
diff_r2
[
"
properties
"
]
assert
"
tests_234234
"
in
diff_r1
[
"
properties
"
]
assert
"
tests_TT
"
in
diff_r2
[
"
properties
"
]
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