Skip to content

Commit 32917bb

Browse files
committed
Added simple user data tests.
1 parent a1aa63a commit 32917bb

2 files changed

Lines changed: 49 additions & 8 deletions

File tree

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
status: 200
2-
x-ratelimit-remaining: 59
1+
status: 304
2+
x-ratelimit-remaining: 56
33
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
74
connection: keep-alive
5+
content-length: 386
6+
server: nginx/0.7.67
7+
x-runtime: 16ms
88
x-ratelimit-limit: 60
9-
etag: "53961f440447e2770b1386199b7a6ef3"
9+
etag: "144f668d7265bcd9d61bc1fb91e9caeb"
1010
cache-control: private, max-age=0, must-revalidate
11-
date: Mon, 11 Apr 2011 14:45:49 GMT
11+
date: Sun, 22 May 2011 04:32:12 GMT
1212
content-type: application/json; charset=utf-8
1313

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"}}
14+
{"user":{"gravatar_id":"b8dbb1987e8e5318584865f880036796","company":"GitHub","name":"Chris Wanstrath","created_at":"2007/10/19 22:24:19 -0700","location":"San Francisco","public_repo_count":90,"public_gist_count":277,"blog":"http://chriswanstrath.com/","following_count":212,"id":2,"type":"User","permission":null,"followers_count":2593,"login":"defunkt","email":"chris@wanstrath.com"}}

tests/test_user.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import _setup
2+
3+
import unittest
4+
5+
from nose.tools import assert_equals
6+
7+
import utils
8+
9+
from github2.client import Github
10+
11+
12+
class UserProperties(unittest.TestCase):
13+
"""Test user property handling"""
14+
def setUp(self):
15+
utils.set_http_mock()
16+
self.client = Github()
17+
18+
def tearDown(self):
19+
utils.unset_http_mock()
20+
21+
def test_user(self):
22+
user = self.client.users.show('defunkt')
23+
assert_equals(user.blog, 'http://chriswanstrath.com/')
24+
assert_equals(user.company, 'GitHub')
25+
assert_equals(user.email, 'chris@wanstrath.com')
26+
assert_equals(user.location, 'San Francisco')
27+
assert_equals(user.login, 'defunkt')
28+
assert_equals(user.name, 'Chris Wanstrath')
29+
30+
def test_meta(self):
31+
user = self.client.users.show('defunkt')
32+
# Difficult to handle created_at attribute as its content varies
33+
# depending on API path.
34+
#assert_equals(user.created_at,
35+
# datetime.datetime(2007, 10, 19, 22, 24, 19))
36+
assert_equals(user.followers_count, 2593)
37+
assert_equals(user.following_count, 212)
38+
assert_equals(user.gravatar_id, 'b8dbb1987e8e5318584865f880036796')
39+
assert_equals(user.id, 2)
40+
assert_equals(user.public_gist_count, 277)
41+
assert_equals(user.public_repo_count, 90)

0 commit comments

Comments
 (0)