Skip to content

Commit ad8e985

Browse files
committed
Updated rate-limit test to use saved data.
1 parent f473130 commit ad8e985

3 files changed

Lines changed: 37 additions & 5 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
status: 200
2+
x-ratelimit-remaining: 59
3+
content-location: https://github.com/api/v2/json/user/show/defunkt
4+
x-runtime: 233ms
5+
content-length: 390
6+
server: nginx/0.7.67
7+
connection: keep-alive
8+
x-ratelimit-limit: 60
9+
etag: "53961f440447e2770b1386199b7a6ef3"
10+
cache-control: private, max-age=0, must-revalidate
11+
date: Mon, 11 Apr 2011 14:45:49 GMT
12+
content-type: application/json; charset=utf-8
13+
14+
{"user":{"gravatar_id":"b8dbb1987e8e5318584865f880036796","company":"GitHub","name":"Chris Wanstrath","created_at":"2007/10/19 22:24:19 -0700","location":"San Francisco, CA","public_repo_count":92,"public_gist_count":277,"blog":"http://chriswanstrath.com/","following_count":212,"id":2,"type":"User","permission":null,"followers_count":2244,"login":"defunkt","email":"chris@wanstrath.com"}}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
status: 200
2+
x-ratelimit-remaining: 58
3+
content-location: https://github.com/api/v2/json/user/show/mojombo
4+
x-runtime: 23ms
5+
content-length: 391
6+
server: nginx/0.7.67
7+
connection: keep-alive
8+
x-ratelimit-limit: 60
9+
etag: "45a6fa1730ba70b40ccd595130b2390e"
10+
cache-control: private, max-age=0, must-revalidate
11+
date: Mon, 11 Apr 2011 14:46:22 GMT
12+
content-type: application/json; charset=utf-8
13+
14+
{"user":{"gravatar_id":"25c7c18223fb42a4c6ae1c8db6f50f9b","company":"GitHub, Inc.","name":"Tom Preston-Werner","created_at":"2007/10/19 22:24:19 -0700","location":"San Francisco","public_repo_count":49,"public_gist_count":66,"blog":"http://tom.preston-werner.com","following_count":11,"id":1,"type":"User","permission":null,"followers_count":1454,"login":"mojombo","email":"tom@github.com"}}

tests/unit.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ def test_issue(self):
4545

4646

4747
class RateLimits(unittest.TestCase):
48-
"""
49-
How should we handle actual API calls such that tests can run?
50-
Perhaps the library should support a ~/.python_github2.conf from which to
51-
get the auth?
52-
"""
48+
"""Test API rate-limitting"""
49+
def setUp(self):
50+
self.old_httplib2 = httplib2.Http
51+
httplib2.Http = HttpMock
52+
53+
def tearDown(self):
54+
httplib2.Http = self.old_httplib2
55+
5356
def test_delays(self):
57+
"""Test call delay is at least one second"""
5458
import datetime
5559
USERNAME = ''
5660
API_KEY = ''

0 commit comments

Comments
 (0)