File tree Expand file tree Collapse file tree 3 files changed +2
-33
lines changed
Expand file tree Collapse file tree 3 files changed +2
-33
lines changed Original file line number Diff line number Diff line change 1818
1919API_URL = "https://api.github.com/graphql"
2020
21- """
22- Rate limit threshold (percent)
23- 10 percent of limit is left for users
24- """
25- RATE_LIMIT_THRESHOLD = 0.1
26-
2721_log = logging .getLogger (__name__ )
2822
2923"""
@@ -210,7 +204,6 @@ def parse_json(json, project):
210204 # We need to check limit first,
211205 # because exceeding the limit will also return error
212206 try :
213- limit = json ["data" ]["rateLimit" ]["limit" ]
214207 remaining = json ["data" ]["rateLimit" ]["remaining" ]
215208 reset_time = json ["data" ]["rateLimit" ]["resetAt" ]
216209 _log .debug (
@@ -219,7 +212,7 @@ def parse_json(json, project):
219212 reset_time ,
220213 )
221214
222- if ( remaining / limit ) <= RATE_LIMIT_THRESHOLD :
215+ if remaining <= 0 :
223216 raise RateLimitException (reset_time )
224217 except KeyError :
225218 _log .info ("Github API ratelimit key is missing. Checking for errors." )
Original file line number Diff line number Diff line change @@ -627,31 +627,6 @@ def test_parse_json_threshold_exceeded(self):
627627 backend .parse_json (json , self .project )
628628 self .assertEqual (backend .reset_time , "2008-09-03T20:56:35.450686" )
629629
630- def test_parse_json_threshold_reached (self ):
631- """
632- Assert that exception is thrown when
633- rate limit threshold is reached.
634- """
635- project = models .Project (
636- name = "foobar" ,
637- homepage = "https://foobar.com" ,
638- version_url = "foo/bar" ,
639- backend = BACKEND ,
640- )
641- json = {
642- "data" : {
643- "repository" : {"refs" : {"totalCount" : 0 }},
644- "rateLimit" : {
645- "limit" : 5000 ,
646- "remaining" : 500 ,
647- "resetAt" : "2008-09-03T20:56:35.450686" ,
648- },
649- }
650- }
651- with self .assertRaises (RateLimitException ):
652- backend .parse_json (json , project )
653- self .assertEqual (backend .reset_time , "2008-09-03T20:56:35.450686" )
654-
655630 def test_parse_json_tag_missing (self ):
656631 """Test parsing a JSON skips releases where tag is missing."""
657632 project = models .Project (
Original file line number Diff line number Diff line change 1+ Remove ratelimit threshold for GitHub
You can’t perform that action at this time.
0 commit comments