Skip to content

Commit ed0c7aa

Browse files
committed
Use an authenticated client, where necessary, in user tests.
1 parent 6e8f844 commit ed0c7aa

2 files changed

Lines changed: 27 additions & 19 deletions

File tree

tests/data/github.com,api,v2,json,user,show,fake_jnrowe_with_auth,3332dc348e8a0f294ffd182b06f12a54 renamed to tests/data/github.com,api,v2,json,user,show,access_token=xxx,c4b85d41b23f289441ee9b8455209d9c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
status: 304
22
x-ratelimit-remaining: 58
3-
content-location: https://github.com/api/v2/json/user/show
3+
content-location: https://github.com/api/v2/json/user/show?access_token=xxx
44
connection: keep-alive
55
content-length: 562
66
server: nginx/0.7.67

tests/test_user.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,9 @@ def test_followers(self):
3737
def test_following(self):
3838
assert_equals(len(self.client.users.following('defunkt')), 212)
3939

40-
def test_is_authenticated(self):
40+
def test_is_not_authenticated(self):
4141
user = self.client.users.show('defunkt')
4242
assert_true(user.is_authenticated() is False)
43-
user = self.client.users.show('fake_jnrowe_with_auth')
44-
assert_true(user.is_authenticated() is True)
45-
46-
def test_private_data(self):
47-
user = self.client.users.show('fake_jnrowe_with_auth')
48-
assert_equals(user.total_private_repo_count, 0)
49-
assert_equals(user.collaborators, 0)
50-
assert_equals(user.disk_usage, 66069)
51-
assert_equals(user.owned_private_repo_count, 0)
52-
assert_equals(user.private_gist_count, 7)
53-
54-
def test_plan_data(self):
55-
user = self.client.users.show('fake_jnrowe_with_auth')
56-
assert_equals(user.plan['name'], "free")
57-
assert_equals(user.plan['collaborators'], 0)
58-
assert_equals(user.plan['space'], 307200)
59-
assert_equals(user.plan['private_repos'], 0)
6043

6144

6245
class UserQueries(utils.HttpMockTestCase):
@@ -82,3 +65,28 @@ def test_follow(self):
8265
def test_unfollow(self):
8366
result = self.client.users.unfollow('defunkt')
8467
assert_false('defunkt' in result['users'])
68+
69+
def test_is_authenticated(self):
70+
user = self.client.users.show('')
71+
assert_true(user.is_authenticated() is True)
72+
73+
74+
class AuthenticatedUserProperties(utils.HttpMockTestCase):
75+
def setUp(self):
76+
super(AuthenticatedUserProperties, self).setUp()
77+
self.client = Github(access_token='xxx')
78+
79+
def test_private_data(self):
80+
user = self.client.users.show('')
81+
assert_equals(user.total_private_repo_count, 0)
82+
assert_equals(user.collaborators, 0)
83+
assert_equals(user.disk_usage, 66069)
84+
assert_equals(user.owned_private_repo_count, 0)
85+
assert_equals(user.private_gist_count, 7)
86+
87+
def test_plan_data(self):
88+
user = self.client.users.show('')
89+
assert_equals(user.plan['name'], "free")
90+
assert_equals(user.plan['collaborators'], 0)
91+
assert_equals(user.plan['space'], 307200)
92+
assert_equals(user.plan['private_repos'], 0)

0 commit comments

Comments
 (0)