File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 11import base
22import github3
33from base import expect
4- from github3 .users import User , Plan
4+ from github3 .users import User , Plan , Key
55from 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 ()
You can’t perform that action at this time.
0 commit comments