Skip to content

Commit 6210bca

Browse files
committed
Finish covering users.
1 parent 134a01e commit 6210bca

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎github3/github.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def follow(self, login):
228228
resp = self._boolean(self._put(url), 204, 404)
229229
return resp
230230

231-
def get_key(self, id_num):
231+
def key(self, id_num):
232232
"""Gets the authenticated user's key specified by id_num.
233233
234234
:param id_num: (required), unique id of the key

‎tests/test_users.py‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import base
22
import github3
33
from base import expect
4-
from github3.users import User, Plan
4+
from github3.users import User, Plan, Key
55
from github3.events import Event
66

77

@@ -71,3 +71,37 @@ def test_authenticated(self):
7171
except github3.GitHubError:
7272
pass
7373
expect(user.update()).isinstance(bool)
74+
75+
76+
class TestKey(base.BaseTest):
77+
def __init__(self, methodName='runTest'):
78+
super(TestKey, self).__init__(methodName)
79+
if self.auth:
80+
self.key = self._g.list_keys()[0]
81+
else:
82+
json = {
83+
'url': 'https://api.github.com/user/keys/id',
84+
'verified': True,
85+
'id': 999999,
86+
'key': 'ssh-rsa AAAAB4...',
87+
'title': 'fake'
88+
}
89+
self.key = Key(json)
90+
91+
def test_key(self):
92+
expect(self.key).isinstance(Key)
93+
94+
def test_pubkey(self):
95+
expect(self.key.key).isinstance(base.str_test)
96+
97+
def test_id(self):
98+
expect(self.key.id) > 0
99+
100+
def test_title(self):
101+
expect(self.key.title).isinstance(base.str_test)
102+
103+
def test_requires_auth(self):
104+
if not self.auth:
105+
with expect.raises(github3.GitHubError):
106+
self.key.update('title', 'ssha-rsa AAAAB2...')
107+
self.key.delete()

0 commit comments

Comments
 (0)