-
Notifications
You must be signed in to change notification settings - Fork 426
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
Replace storage.update_annotation
with an AnnotationWriteService
method
#7967
Conversation
6dd5530
to
6c02aa7
Compare
bd0cf21
to
f7b8ffd
Compare
6c02aa7
to
85e6b8d
Compare
f7b8ffd
to
c2c782e
Compare
f06bb09
to
aa848a2
Compare
c2c782e
to
9b3abf2
Compare
ae2d4fd
to
8d3b6d1
Compare
data: dict, | ||
update_timestamp: bool = True, | ||
reindex_tag: str = "storage.update_annotation", | ||
enforce_write_permission: bool = True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to move the migration stuff to this service, at which point a lot of these args would become private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default of enforce_write_permission
here is a change in behavior. Previously we never did this. Now we do it when updating on behalf of the user.
# the target URI must match one of a group's defined scopes | ||
and not url_in_scope( | ||
annotation.target_uri, [scope.scope for scope in group.scopes] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small un-related refactor to point out these are two parts of the same condition.
def celery(self, patch, pyramid_request): | ||
celery = patch("h.tasks.url_migration.celery") | ||
celery.request = pyramid_request | ||
return celery |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was having some untraceable coverage issues, and this seemed related, and a good thing to fix.
@@ -34,6 +34,7 @@ def test_it_captures_initial_errors(self): | |||
def failing_method(): | |||
raise ValueError("Oh no!") | |||
|
|||
# pragma: nocover | |||
yield 1 # pylint: disable=unreachable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random coverage fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting of value to add here. Changes make sense and the code is in much better shape now.
Tried the testing instruction and discovered that URL migration interface in the process.
@@ -5,97 +5,15 @@ | |||
for storing and retrieving annotations. Data passed to these functions is | |||
assumed to be validated. | |||
""" | |||
# FIXME: This module was originally written to be a single point of | |||
# indirection through which the storage backend could be swapped out on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
originally written to be a single point of indirection
Oh well, that didn't happen
# Don't update "edited" timestamp on annotation cards. | ||
update_timestamp=False, | ||
reindex_tag="URLMigrationService.move_annotations", | ||
# This action is taken by the admin user most of the time, who |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the time?
# pylint: disable=too-many-arguments | ||
self, | ||
annotation: Annotation, | ||
data: dict, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in the scope of this PR but these APIs where we just have some "data" in with no shape or form are difficult to change.
Some changes work because everything is very abstract but other times is tricky to spot a problem because it will silently fail or just do nothing.
Anyway, just rambling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's confusing as the data is a very specific shape, but what shape is that?
8d3b6d1
to
53d904e
Compare
This matches the formulation in the tests and keeps this a unitary piece of logic, rather than split over two separate tests. This form has less chance of getting split up in a weird way in a refactor.
We can't enforce the group based on the current user when that user is an admin.
53d904e
to
bac2495
Compare
For:
Requires:
storage.create_annotation
with anAnnotationWriteService
#7966Testing notes
h
, the client, Via and ViaHTMLUpdate annotation
devdata_user
/pass
Migrate annotation URL
devdata_admin
/pass
h-periodic
to enable re-indexing of the annotations