class TestKey(base.BaseTest): def __init__(self, methodName='runTest'): super(TestKey, self).__init__(methodName) if self.auth: self.key = self._g.list_keys()[0] else: json = { 'url': 'https://api.github.com/user/keys/id', 'verified': True, 'id': 999999, 'key': 'ssh-rsa AAAAB4...', 'title': 'fake' } self.key = Key(json) def test_key(self): expect(self.key).isinstance(Key) def test_pubkey(self): expect(self.key.key).isinstance(base.str_test) def test_id(self): expect(self.key.id) > 0 def test_title(self): expect(self.key.title).isinstance(base.str_test) def test_requires_auth(self): if not self.auth: with expect.raises(github3.GitHubError): self.key.update('title', 'ssha-rsa AAAAB2...') self.key.delete()
class TestKey(base.BaseTest): def __init__(self, methodName='runTest'): super(TestKey, self).__init__(methodName) if self.auth: self.key = self._g.list_keys()[0] else: json = { 'url': 'https://api.github.com/user/keys/id', 'verified': True, 'id': 999999, 'key': 'ssh-rsa AAAAB4...', 'title': 'fake' } self.key = Key(json) def test_key(self): expect(self.key).isinstance(Key) expect(repr(self.key)) != '' self.key._update_(self.key.to_json()) def test_pubkey(self): expect(self.key.key).isinstance(base.str_test) def test_id(self): expect(self.key.id) > 0 def test_title(self): expect(self.key.title).isinstance(base.str_test) def test_requires_auth(self): if self.auth: return self.raisesGHE(self.key.update, 'title', 'ssha-rsa AAAAB2...') self.raisesGHE(self.key.delete) def test_with_auth(self): if not self.auth: return expect(self.key.update(None, None)).is_False() expect(self.key.update(self.key.title, self.key.key)).is_True()