mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
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:
+4
-1
@@ -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
|
||||
|
||||
@@ -123,3 +123,12 @@ class SpecificExceptions(Framework.TestCase):
|
||||
g.get_user("jacquev6")
|
||||
|
||||
self.assertRaises(github.RateLimitExceededException, exceed)
|
||||
|
||||
def testAuthenticatedRateLimitExceeded(self):
|
||||
|
||||
def exceed():
|
||||
for i in range(100):
|
||||
res = self.g.search_code("jacquev6")
|
||||
res.get_page(0)
|
||||
|
||||
self.assertRaises(github.RateLimitExceededException, exceed)
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user