Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

refactor: refine the Handler validation #870

Merged
merged 1 commit into from
Apr 14, 2017
Merged

refactor: refine the Handler validation #870

merged 1 commit into from
Apr 14, 2017

Conversation

pjenvey
Copy link
Member

@pjenvey pjenvey commented Apr 13, 2017

closes #695

@codecov-io
Copy link

codecov-io commented Apr 13, 2017

Codecov Report

Merging #870 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #870    +/-   ##
======================================
  Coverage     100%   100%            
======================================
  Files          50     50            
  Lines        9570   9883   +313     
======================================
+ Hits         9570   9883   +313
Impacted Files Coverage Δ
autopush/tests/test_log_check.py 100% <100%> (ø) ⬆️
autopush/web/webpush.py 100% <100%> (ø) ⬆️
autopush/tests/test_endpoint.py 100% <100%> (ø) ⬆️
autopush/web/base.py 100% <100%> (ø) ⬆️
autopush/web/simplepush.py 100% <100%> (ø) ⬆️
autopush/web/registration.py 100% <100%> (ø) ⬆️
autopush/tests/test_web_webpush.py 100% <100%> (ø) ⬆️
autopush/web/health.py 100% <100%> (ø) ⬆️
autopush/jwt.py 100% <100%> (ø) ⬆️
autopush/web/message.py 100% <100%> (ø) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b60fcb...b1312db. Read the comment docs.

def _make_test_data(self, headers=None, body="", path_args=None,
path_kwargs=None, arguments=None):
def _make_test_data(self, headers=None, body="", args=None, kwargs=None,
arguments=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm. While it feels like a nit, args vs. arguments might be a bit confusing. Granted, path_args wasn't terribly great either, but at least it reflected what it was used for.

Since it's kinda/sorta unused. I suppose we could just drop the args for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same thought and forgot all about it, I was thinking of renaming arguments (how about request_arguments?) it's rarely used anyway

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh, maybe still a bit confusing..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, like I said, a bit more nitty than needed. I'm also fine with just dropping "args" since I don't think that anything actually passes them. Calling "arguments" request_arguments might be good. Granted, shortening down 'kwargs' and tossing it into the middle of the arg list might cause a few python folk to twitch, but none of that is super critical.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Punting on this for now, I'll revisit it later. cyclone apparently sets up path_args/kwargs for use by the prepare method, so I guess there's a small case to keep the naming, but I wouldn't mind shortening. the websocket handlers still use regular args (though they don't validate), should probably switch those over

@@ -133,6 +137,41 @@ def validate_data(self, data):
errno=109,
headers=request_pref_header)

@post_load
def handler_kwargs(self, data):
# not used
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this just pops it off the handler kwargs after it's validated (not used = not used by the handlers)

"uaid": uaid,
"chid": chid}
return dict()
def _req(self, m, router_type="", router_token="", uaid=None, chid=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m?

class RouterInfo(object):
"""Bundle of Router registration information"""

router = attrib() # type: Any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really Any? I thought there were only a few valid sets of things it could be.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's IRouter, however, mypy doesn't yet understand zope.interface

- instead of valid_input call handler methods w/ the resulting dict as
args/kwargs (similarly to how cyclone does)
- bundle router info together in registration to ease passing it around
- kill the now unneeded MessageSchema args/kwargs shuffle and its
associated test_delete_topic_success2
- fix LogCheckSchema typo

closes #695
@bbangert bbangert merged commit 06649de into master Apr 14, 2017
@bbangert bbangert deleted the refactor/695 branch April 14, 2017 04:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

further refine Handler validation
4 participants