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
18aef0cf
Commit
18aef0cf
authored
1 year ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
TST: more tests for apiutils
parent
86311b39
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!107
ENH: add entity getters and cached functions
,
!103
Improving the compare_entities functions
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_apiutils.py
+27
-5
27 additions, 5 deletions
unittests/test_apiutils.py
with
27 additions
and
5 deletions
unittests/test_apiutils.py
+
27
−
5
View file @
18aef0cf
...
...
@@ -101,15 +101,15 @@ def test_compare_entities():
r2
=
db
.
Record
()
r1
.
add_parent
(
"
bla
"
)
r2
.
add_parent
(
"
bla
"
)
r1
.
add_parent
(
"
lopp
"
)
r1
.
add_parent
(
"
lopp
"
)
# r1 has one additional parent
r1
.
add_property
(
"
test
"
,
value
=
2
)
r2
.
add_property
(
"
test
"
,
value
=
2
)
r2
.
add_property
(
"
test
"
,
value
=
2
)
# a property with the same value
r1
.
add_property
(
"
tests
"
,
value
=
3
)
r2
.
add_property
(
"
tests
"
,
value
=
45
)
r2
.
add_property
(
"
tests
"
,
value
=
45
)
# a property with different value
r1
.
add_property
(
"
tester
"
,
value
=
3
)
r2
.
add_property
(
"
tester
"
,
)
r2
.
add_property
(
"
tester
"
,
)
# a property where r2 has no value
r1
.
add_property
(
"
tests_234234
"
,
value
=
45
)
r2
.
add_property
(
"
tests_TT
"
,
value
=
45
)
r2
.
add_property
(
"
tests_TT
"
,
value
=
45
)
# one additional property that the other one does not have for both
diff_r1
,
diff_r2
=
compare_entities
(
r1
,
r2
)
...
...
@@ -130,6 +130,28 @@ def test_compare_entities():
assert
"
tests_234234
"
in
diff_r1
[
"
properties
"
]
assert
"
tests_TT
"
in
diff_r2
[
"
properties
"
]
def
test_compare_equality
():
r1
=
db
.
Record
()
r2
=
db
.
Record
()
diff_r1
,
diff_r2
=
compare_entities
(
r1
,
r2
)
for
i
in
(
"
parents
"
,
"
properties
"
):
assert
len
(
diff_r1
[
i
])
==
0
assert
len
(
diff_r2
[
i
])
==
0
assert
empty_diff
(
r1
,
r2
)
r1
.
add_parent
(
"
bla
"
)
r2
.
add_parent
(
"
bla
"
)
assert
empty_diff
(
r1
,
r2
)
r1
.
add_property
(
"
test
"
,
value
=
2
)
r2
.
add_property
(
"
test
"
,
value
=
2
)
# a property with the same value
diff_r1
,
diff_r2
=
compare_entities
(
r1
,
r2
)
assert
empty_diff
(
r1
,
r2
)
r1
.
add_parent
(
"
blobb
"
)
r2
.
add_parent
(
"
blobb
"
)
assert
empty_diff
(
r1
,
r2
)
def
test_compare_entities_units
():
r1
=
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