-
Notifications
You must be signed in to change notification settings - Fork 192
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
Fix #1228 - Improves webhooks to send labels at once #1566
Conversation
- We use the LOCALHOST key for testing - Takes this opportunity to straighten a bit the way we create import.
We might want to do that in the future but for now, it is basically unused code.
The goal is to make the function more usable in web hooks tests. We now have a function to check and one to compute a signature. It makes also fixtures independent with regards to content change.
Only one case is not tested for now, when basically we are communicating with GitHub. There are a couple of strategies for mocking the service. It needs a bit more cycles of thinking.
- Removes the GET. Flask handles this already for us - Creates only 1 requests for setting labels instead of two, probably avoiding race condition mentioned in webcompat#1553 - Sends plain/text messages where it is granted. - Logs the failure when tagging didn’t happen properly - Renames set_label as set_labels and rationalises the functions
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.
LGTM. Just a few minor questions -- thanks Karl!
tests/test_webhook.py
Outdated
|
||
# Any request that depends on parsing HTTP Headers (basically anything | ||
# on the index route, will need to include the following: environ_base=headers | ||
headers = {'HTTP_USER_AGENT': ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; ' |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
webcompat/webhooks/helpers.py
Outdated
} | ||
uri = 'https://api.github.com/repos/{0}/{1}/labels'.format( | ||
app.config['ISSUES_REPO_URI'], issue_number) | ||
return requests.post(uri, data=json.dumps(payload), headers=headers) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@miketaylr Modifications done. |
Thanks Karl. Let's merge. |
r? @miketaylr
Instead of sending two requests which might have created the issue #1553, we are now sending one request only.
We also created a bunch of additional tests in their own file.
Comments in each commit have additional details explaining the context.
You can test locally the Webhook by doing.
Testing
or for just testing the webhook.