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
bdc88dfc
Commit
bdc88dfc
authored
4 months ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
TST: add test cases for compare entities
parent
58166513
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!159
Release 0.16.o
,
!157
compare entities and parent/property lists
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_apiutils.py
+35
-3
35 additions, 3 deletions
unittests/test_apiutils.py
with
35 additions
and
3 deletions
unittests/test_apiutils.py
+
35
−
3
View file @
bdc88dfc
...
...
@@ -111,13 +111,25 @@ 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
)
r1
.
add_property
(
"
entity_id
"
,
value
=
2
)
r2
.
add_property
(
"
entity_id
"
,
value
=
24
)
r1
.
add_property
(
"
entity_mix_e
"
,
value
=
2
)
r2
.
add_property
(
"
entity_mix_e
"
,
value
=
db
.
Entity
(
id
=
2
))
r1
.
add_property
(
"
entity_mix_d
"
,
value
=
22
)
r2
.
add_property
(
"
entity_mix_d
"
,
value
=
db
.
Entity
(
id
=
2
))
r1
.
add_property
(
"
entity_Ent_e
"
,
value
=
db
.
Entity
(
id
=
2
))
r2
.
add_property
(
"
entity_Ent_e
"
,
value
=
db
.
Entity
(
id
=
2
))
r1
.
add_property
(
"
entity_Ent_d
"
,
value
=
db
.
Entity
(
id
=
2
))
r2
.
add_property
(
"
entity_Ent_d
"
,
value
=
db
.
Entity
(
id
=
22
))
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
"
])
==
10
assert
len
(
diff_r2
[
"
properties
"
])
==
10
assert
"
test
"
not
in
diff_r1
[
"
properties
"
]
assert
"
test
"
not
in
diff_r2
[
"
properties
"
]
...
...
@@ -135,6 +147,19 @@ def test_compare_entities():
assert
"
tests_TT
"
in
diff_r2
[
"
properties
"
]
assert
"
entity_id
"
in
diff_r1
[
"
properties
"
]
assert
"
entity_id
"
in
diff_r2
[
"
properties
"
]
assert
"
entity_mix_e
"
in
diff_r1
[
"
properties
"
]
assert
"
entity_mix_e
"
in
diff_r2
[
"
properties
"
]
assert
"
entity_Ent_e
"
in
diff_r1
[
"
properties
"
]
assert
"
entity_Ent_e
"
in
diff_r2
[
"
properties
"
]
assert
"
entity_mix_d
"
in
diff_r1
[
"
properties
"
]
assert
"
entity_mix_d
"
in
diff_r2
[
"
properties
"
]
assert
"
entity_Ent_d
"
in
diff_r1
[
"
properties
"
]
assert
"
entity_Ent_d
"
in
diff_r2
[
"
properties
"
]
def
test_compare_entities_units
():
r1
=
db
.
Record
()
r2
=
db
.
Record
()
...
...
@@ -572,12 +597,19 @@ B: something else"""
# test whether an id is correctly overwritten by an entity without id
recA
=
db
.
Record
().
add_parent
(
"
A
"
).
add_property
(
name
=
"
B
"
,
value
=
112
)
newRec
=
db
.
Record
()
newRec
=
db
.
Record
()
.
add_parent
(
"
B
"
).
add_property
(
"
c
"
)
recB
=
db
.
Record
().
add_parent
(
"
A
"
).
add_property
(
name
=
"
B
"
,
value
=
newRec
)
merge_entities
(
recA
,
recB
,
force
=
True
)
assert
recA
.
get_property
(
"
B
"
).
value
==
newRec
recA
=
db
.
Record
().
add_parent
(
"
A
"
).
add_property
(
name
=
"
B
"
,
value
=
[
112
],
datatype
=
db
.
LIST
(
"
B
"
))
recB
=
db
.
Record
().
add_parent
(
"
A
"
).
add_property
(
name
=
"
B
"
,
value
=
[
newRec
],
datatype
=
db
.
LIST
(
db
.
REFERENCE
))
merge_entities
(
recA
,
recB
,
force
=
True
)
assert
recA
.
get_property
(
"
B
"
).
value
==
[
newRec
]
def
test_merge_missing_list_datatype_82
():
"""
Merging two properties, where the list-valued one has no datatype.
"""
...
...
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