-
Notifications
You must be signed in to change notification settings - Fork 193
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
Fixes #2479 - Refactors the form to be more testable #2528
Conversation
This adds a function which can be augmented in the future to check form parameters This adds the test for this function.
By starting the logger early up, we can use it to track failures here and there.
This creates an helper to check if the domain is blacklisted. Probably this can evolve into something more refined where the blacklist is maintained in the config file and not in the code.
Travis tests have failedHey @karlcow, 1st Buildnosetests
sleep 5
|
@miketaylr if I didn't mess up. I have rebased this pull request on today's version of the master. |
|
Oops Sorry Travis. |
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!
Very nice commits, and easy to review. Thanks for all the new tests.
Just one question about removing .json()
tests/unit/test_form.py
Outdated
@@ -213,6 +213,20 @@ def test_is_valid_issue_form(self): | |||
('username', u''), | |||
]) | |||
self.assertTrue(helpers.is_valid_issue_form(valid_form)) | |||
# The value for submit-Type can be only: |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@@ -42,6 +61,43 @@ def test_new_issue(self): | |||
rv = self.app.get('/issues/new', environ_base=headers) | |||
self.assertEqual(rv.status_code, 200) | |||
|
|||
@patch('webcompat.views.report_issue') | |||
def test_successful_post_new_issue(self, mock_proxy): |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
webcompat/views.py
Outdated
@@ -232,7 +235,7 @@ def create_issue(): | |||
session['form_data'] = form | |||
return redirect(url_for('login')) | |||
elif form.get('submit_type') == PROXY_REPORT: | |||
response = report_issue(form, proxy=True).json() | |||
response = report_issue(form, proxy=True) |
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.
webcompat/helpers.py
Outdated
@@ -568,8 +568,7 @@ def is_valid_issue_form(form): | |||
'problem_category', | |||
'submit_type', | |||
'url', | |||
'username', | |||
] | |||
'username', ] |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
making current status more visible: #2528 (comment) |
webcompat.com/webcompat/issues.py Lines 18 to 26 in 1cdfbe3
One time in webcompat.com/webcompat/views.py Lines 127 to 142 in 1cdfbe3
Twice in webcompat.com/webcompat/views.py Lines 223 to 239 in 1cdfbe3
The response is not used for anything else Let's make things easier, then and return just what we need. :) |
|
|
I could have simplified more report_issue. but it really reports an issue. :) |
Before report_issue was reporting either a JSON as dict, either a response object, this makes it uniform so it will only report JSON data as a dict. It simplifies testing and make it less… surprising. :) If in the future we need the access to status, we can revisit this and makes it return response but uniformly.
OK Let's see if travis is happy :) then @miketaylr it's all yours. :) Basically report_issue was non uniform, it was returning a Response object when anonymous, and a JSON dict when logged. I changed the logic. so it always returns JSON as dict. |
thanks for cleaning this up! |
This PR fixes issue #2479
Proposed PR background
The intent is to
r? @miketaylr