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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
3566b6b5
Commit
3566b6b5
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Plain Diff
Merge branch 'f-fix-empty-diff' into 'dev'
F fix empty diff See merge request
!76
parents
9900131a
1b2722c5
No related branches found
No related tags found
2 merge requests
!79
Release 0.10.0
,
!76
F fix empty diff
Pipeline
#30220
failed
2 years ago
Stage: code_style
Stage: linting
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
src/caosdb/apiutils.py
+5
-1
5 additions, 1 deletion
src/caosdb/apiutils.py
unittests/test_apiutils.py
+9
-0
9 additions, 0 deletions
unittests/test_apiutils.py
with
16 additions
and
1 deletion
CHANGELOG.md
+
2
−
0
View file @
3566b6b5
...
...
@@ -36,6 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ###
*
handling of special attributes (name, id, ...) in
`apiutils.empty_diff`
### Security ###
### Documentation ###
...
...
This diff is collapsed.
Click to expand it.
src/caosdb/apiutils.py
+
5
−
1
View file @
3566b6b5
...
...
@@ -353,10 +353,14 @@ def empty_diff(old_entity: Entity, new_entity: Entity, compare_referenced_record
olddiff
,
newdiff
=
compare_entities
(
old_entity
,
new_entity
,
compare_referenced_records
)
for
diff
in
[
olddiff
,
newdiff
]:
for
key
in
diff
:
for
key
in
[
"
parents
"
,
"
properties
"
]
:
if
len
(
diff
[
key
])
>
0
:
# There is a difference somewhere in the diff
return
False
for
key
in
SPECIAL_ATTRIBUTES
:
if
key
in
diff
and
diff
[
key
]:
# There is a difference in at least one special attribute
return
False
# all elements of the two diffs were empty
return
True
...
...
This diff is collapsed.
Click to expand it.
unittests/test_apiutils.py
+
9
−
0
View file @
3566b6b5
...
...
@@ -466,6 +466,15 @@ def test_empty_diff():
assert
not
empty_diff
(
rec_a
,
rec_b
)
assert
empty_diff
(
rec_a
,
rec_b
,
compare_referenced_records
=
True
)
# special case of ids
rec_a
=
db
.
Record
(
id
=
12
)
rec_b
=
db
.
Record
()
assert
not
empty_diff
(
rec_a
,
rec_b
)
rec_b
.
id
=
13
assert
not
empty_diff
(
rec_a
,
rec_b
)
rec_b
.
id
=
12
assert
empty_diff
(
rec_a
,
rec_b
)
def
test_force_merge
():
"""
Test whether a forced merge overwrites existing properties correctly.
"""
...
...
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