Fixes #2006: Add support for multiple label and details params.#2007
Fixes #2006: Add support for multiple label and details params.#2007
label and details params.#2007Conversation
| return extra_label | ||
| def extract_extra_labels(metadata_dict): | ||
| """Return the 'extra_labels' labels from metadata_dict, as a list.""" | ||
| # we have to handle the ', ' foo biz here. |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| extra_labels = metadata_dict.get('extra_labels', None) | ||
| if extra_labels: | ||
| extra_labels = extra_labels.split(', ') | ||
| print(extra_labels) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| extra_labels = extract_extra_labels(metadata_dict) | ||
| priority_label = extract_priority_label(issue_body) | ||
| labelslist = [] | ||
| print(browser_label, extra_labels, priority_label) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| priority_label = extract_priority_label(issue_body) | ||
| labelslist = [] | ||
| print(browser_label, extra_labels, priority_label) | ||
| for label in (browser_label, extra_labels, priority_label): |
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.
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.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
ok let's review this. Let's play with the code now. |
karlcow
left a comment
There was a problem hiding this comment.
@miketaylr First round of comments.
| priority_label = extract_priority_label(issue_body) | ||
| labelslist = [] | ||
| print(browser_label, extra_labels, priority_label) | ||
| for label in (browser_label, extra_labels, priority_label): |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| @@ -134,7 +135,8 @@ def test_fails_on_not_known_action(self): | |||
| self.assertEqual(rv.data, 'Not an interesting hook') | |||
|
|
|||
| def test_extract_metadata(self): | |||
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.
| ] | ||
| for issue_body, expected in labels_tests: | ||
| actual = helpers.get_issue_labels(issue_body) | ||
| self.assertEqual(expected, actual) |
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.
| priority_label = extract_priority_label(issue_body) | ||
| labelslist = [] | ||
| print(browser_label, extra_labels, priority_label) | ||
| for label in (browser_label, extra_labels, priority_label): |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| def normalize_metadata(metadata_value): | ||
| """Normalize the metadata received from the form.""" | ||
| # If it's a list, we are dealing with @extra_labels, | ||
| # so convert into a comma separated string. |
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.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| if request.args.get('src'): | ||
| session['src'] = request.args.get('src') | ||
| if request.args.get('label'): | ||
| session['src'] = request.args.getlist('label') |
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.
| extra_labels = metadata_dict.get('extra_labels', None) | ||
| if extra_labels: | ||
| extra_labels = extra_labels.split(', ') | ||
| print(extra_labels) |
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.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| print(extra_labels) | ||
| for idx, label in enumerate(extra_labels): | ||
| extra_labels[idx] = label.lower() | ||
| extra_labels[idx] = label.encode('utf-8') |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| for idx, label in enumerate(extra_labels): | ||
| extra_labels[idx] = label.lower() | ||
| extra_labels[idx] = label.encode('utf-8') | ||
| return extra_labels |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| metadata_tests = [ | ||
| ({'extra_label': 'type-media'}, 'type-media'), | ||
| ({'extra_labels': 'type-media'}, ['type-media']), | ||
| ({'extra_labels': 'cool, dude'}, ['cool', 'dude']), |
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.
|
I have not reviewed the JavaScript. @zoepage do you want to do it? |
|
The JS looks 👍 to me. |
55036af to
e8235cc
Compare
f222419 to
a101404
Compare
| ] | ||
| for issue_body, expected in labels_tests: | ||
| actual = helpers.get_issue_labels(issue_body) | ||
| self.assertEqual(sorted(expected), sorted(actual)) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
Ready for re-review, Karl. r? @karlcow |
karlcow
left a comment
There was a problem hiding this comment.
@miketaylr After removing the typo, this is good to go. Congratulations.
→ nosetests -v --nocapture
Statuses Initialization…
Fetching milestones from Github…
Milestones saved in data/
Milestones in memory
Pagination in comments Link response header. ... ok
API issue for a non existent number returns JSON 404. ... ok
API access to labels without auth returns JSON 200. ... ok
Patching the issue is working only with certain circumstances. ... ok
API with wrong parameter returns JSON 404. ... ok
API setting labels without auth returns JSON 403 error code. ... ok
API access to user activity without auth returns JSON 401. ... ok
API with wrong category returns JSON 404. ... ok
API with wrong route returns JSON 404. ... ok
Check we receive the right list of browsers. ... ok
Assess the filtering is correct. ... ok
Check if a list of labels contains the 'status-needinfo'. ... ok
Check if an issue is older than a certain time gap. ... ok
The data body sent to GitHub API. ... ok
Check that domain name is extracted. ... ok
Checks we return the right form with the appropriate data. ... ok
HTML comments need the right values depending on the keys. ... ok
Check that metadata is processed and wrapped. ... ok
Avoid some type of strings. ... ok
Check that URL is normalized. ... ok
Check that appropriate radio button label is returned. ... ok
Test HTTP Links formating. ... ok
Test browser parsing via get_browser helper method. ... ok
Test browser name parsing via get_browser_name helper method. ... ok
Test name extraction from Dict via get_name helper method. ... ok
Test OS parsing via get_os helper method. ... ok
Test version string composition from Dict ... ok
Test that API params are correctly converted to Search API. ... ok
normalize_api_params shouldn't transform unknown params. ... ok
Test HTTP Links parsing for GitHub only. ... ok
test_rewrite_and_sanitize_link (tests.test_helpers.TestHelpers) ... ok
Test we're correctly rewriting the passed in link. ... ok
Test that we're removing access_token parameters. ... ok
Check Cache-Control for issues. ... ok
Check ETAG for issues. ... ok
Checks if we receive a 304 Not Modified. ... ok
Page title format for different URIs. ... ok
Testing user activity page title. ... ok
test_build_query_string (tests.test_topsites.TestTopsites) ... ok
test_build_uri (tests.test_topsites.TestTopsites) ... ok
test_node_text (tests.test_topsites.TestTopsites) ... ok
Test that Base64 screenshots return the expected status codes. ... ok
Test that /upload/ doesn't let you GET. ... ok
Test that uploaded files return the expected status code. ... ok
Test that /about exists. ... ok
Test that asks user to log in before displaying activity. ... ok
Test POST to /csp-report w/ correct content-type returns 204. ... ok
Test POST w/ wrong content-type to /csp-report returns 400. ... ok
Request to /dashboard should be 404. ... ok
Request to /dashboard/triage should be 200. ... ok
Test that the home page exists. ... ok
Test if issues are really integer. ... ok
Test that the /issues/<number> exists, and does not redirect. ... ok
Test that the /issues route gets 200 and does not redirect. ... ok
Sends 400 to POST on /issues/new with missing parameters. ... ok
Test that /issues/new exists. ... ok
/issues/new POST exit with 400 if missing parameters. ... ok
Test that /privacy exists. ... ok
Rate Limit URI sends 410 Gone. ... ok
Test that the /tools/cssfixme route gets 200. ... ok
Extract browser label name. ... ok
Extract 'extra' label. ... ok
Extract dictionary of metadata for an issue body. ... ok
Extract priority label. ... ok
POST without bogus signature on labeler webhook is forbidden. ... ok
POST with event not being 'issues' or 'ping' fails. ... ok
POST without signature on labeler webhook is forbidden. ... ok
POST with an unknown action fails. ... ok
GET is forbidden on labeler webhook. ... ok
Extract the right information from an issue. ... ok
Extract list of labels from an issue body. ... ok
Validation tests for GitHub Webhooks. ... ok
POST with PING events just return a 200 and contains pong. ... ok
----------------------------------------------------------------------
Ran 73 tests in 3.990s
OK
|
|
||
| def test_extract_metadata(self): | ||
| expected = {'reported_with': 'web', 'extra_label': 'type-media', | ||
| """Extract dictionary of metadata for an issue body.""". |
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.
a101404 to
8f54003
Compare
|
nose tests passing on Travis: https://travis-ci.org/webcompat/webcompat.com/builds/327334792#L639 Let's merge. My plan is to not deploy to prod until Travis is green on master though. |
Our test situation seems FUBAR in Firefox 57+ right now, but these new functional tests pass in Chrome, and nosetests are good.
r? @karlcow
r? @zoepage