Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNO-176-invalidate-object-when-unlinked #303

Merged
merged 1 commit into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/snovault/invalidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ def record_initial_back_revs(event):

@subscriber(Created)
@subscriber(AfterModified)
def invalidate_new_back_revs(event):
def invalidate_changed_back_revs(event):
''' Invalidate objects that rev_link to us

Catch those objects which newly rev_link us
or no longer rev_link us
'''
context = event.object
updated = event.request._updated_uuid_paths
Expand All @@ -57,7 +58,7 @@ def invalidate_new_back_revs(event):
for path in context.type_info.merged_back_rev
}
for rel, uuids in current.items():
for uuid in uuids.difference(initial.get(rel, ())):
for uuid in uuids.symmetric_difference(initial.get(rel, ())):
updated[uuid]


Expand Down
6 changes: 5 additions & 1 deletion src/snovault/tests/test_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ def test_updated_source(content, testapp):
def test_updated_source_changed(content, testapp):
url = '/testing-link-sources/' + sources[0]['uuid']
res = testapp.patch_json(url, {'target': targets[1]['uuid']})
assert set(res.headers['X-Updated'].split(',')) == {sources[0]['uuid'], targets[1]['uuid']}
assert set(res.headers['X-Updated'].split(',')) == {
sources[0]['uuid'],
targets[0]['uuid'],
targets[1]['uuid'],
}


def test_updated_target(content, testapp):
Expand Down