Fix unable to trigger RateLimitExceededException. (#943)

I found when authorized, the ratelimit error message is different from unauthorized.

so i add this.

After studying hard with my 2b colleagues @AnYeMoWang , we finally realized how tests wrote.

😸 😸 😸 😸 😸 😸 😸
This commit is contained in:
Tuuu Nya
2018-10-23 17:03:03 +08:00
committed by Wan Liuyang
parent 8ee75a282b
commit 972446d5bf
3 changed files with 80 additions and 1 deletions
+4 -1
View File
@@ -293,7 +293,10 @@ class Requester:
cls = GithubException.TwoFactorException # pragma no cover (Should be covered)
elif status == 403 and output.get("message").startswith("Missing or invalid User Agent string"):
cls = GithubException.BadUserAgentException
elif status == 403 and output.get("message").lower().startswith("api rate limit exceeded"):
elif status == 403 and (
output.get("message").lower().startswith("api rate limit exceeded")
or output.get("message").lower().endswith("please wait a few minutes before you try again.")
):
cls = GithubException.RateLimitExceededException
elif status == 404 and output.get("message") == "Not Found":
cls = GithubException.UnknownObjectException