-
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 #929 - Make Error management more DRY #958
Conversation
… error codes 400,401,403,404,500
… error codes 400,401,403,404,500
429: 'Cool your jets! Please wait {0} seconds before making' | ||
'another search.', | ||
500: 'Internal Server Error', | ||
GitHubError: 'Something bad happened. Please try again?'} |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Oh and why the additional pull request here? You already started #949 which was not finished. |
I would like to continue with this pull request as I have deleted the repository of the pull request #949 |
@karlcow when I read the code, I realized that GithubError is a class that is getting imported from flask.ext.github. I also read from this link http://stackoverflow.com/questions/7560172/class-as-dictionary-key-in-python that class can be used as a key for Dictionary. I also executed this code snippet in python interpreter before submitting the pull request : class MyError(Exception):
def dee_excep_():
try:
raise MyError(2*2)
except MyError as e:
return e.value
dee_excep_()
ERROR_DICT = { 400: 'Bad Request.',
401: 'Unauthorized. Please log in.',
403: 'Forbidden. Maybe that looking at private stuff?',
404: 'Not Found. Lost in Punk Cat Space',
429: 'Cool your jets! Please wait {0} seconds before making'
' another search.',
500: 'Internal Server Error',
MyError: "'Something bad happened. Please try again?', 'error'"}
print ERROR_DICT[MyError]
print type(ERROR_DICT[MyError]) This executed without any errors. I did make built which did not return any errors. If this is causing the build to fail, I will change the dictionary key from class object to string. |
… error codes 400,401,403,404,500
So currently https://travis-ci.org/webcompat/webcompat.com/builds/115635958#L573 |
@deepthivenkat You need to run nosetests in your own directory and you will see the error messages. |
…y that caused the tests to fail
@@ -61,11 +61,6 @@ def test_activity_page_401_if_not_logged_in(self): | |||
rv = self.app.get('/me') | |||
self.assertEqual(rv.status_code, 401) | |||
|
|||
def test_activity_page_403_view_other_user_activity(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.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@@ -44,8 +43,7 @@ | |||
404: 'Not Found. Lost in Punk Cat Space', | |||
429: 'Cool your jets! Please wait {0} seconds before making' | |||
'another search.', |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
ok let's see
then
Good! r+ |
Ahaha. One small thing to fix. |
So when I run the tests locally I have no issues.
but travis seems to have issues. Let's see
So there is something to explore here and understands why it doesn't fail locally but fails on travis. For example
but if I do:
I get the right thing
hmmm let's see. Maybe just a Travis thing. |
Yeah, it's a Travis thing. It runs into rate limiting probably because it has a shared Travis IP (this is only for tests that make unauthed APy I calls, from a PR from someone who doesn't have access to the secrets. Basically anyone not sending a PR from the webcompat repo itself). On my backlog of things to fix. 🙈 |
Great work @deepthivenkat! |
No description provided.