Skip to content
Snippets Groups Projects
Commit 3566b6b5 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

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!79Release 0.10.0,!76F fix empty diff
Pipeline #30220 failed
......@@ -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 ###
......
......@@ -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
......
......@@ -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."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment