def test_throws_an_exception_if_the_key_is_not_a_real_key(self):
     github_user = Github(username, account_password).get_user()
     try:
         github_user.create_key('someKeyAlias', 'keyValue')
     except Exception as exception:
         self.assertIsInstance(exception, GithubException)
         self.assertIn('key is invalid', exception.data['errors'][0]['message'])
Example #2
0
 def test_throws_an_exception_if_the_key_is_not_a_real_key(self):
     github_user = Github(username, account_password).get_user()
     try:
         github_user.create_key('someKeyAlias', 'keyValue')
     except Exception as exception:
         self.assertIsInstance(exception, GithubException)
         self.assertIn('key is invalid',
                       exception.data['errors'][0]['message'])
 def test_throws_exception_when_key_is_duplicate(self):
     _, public_key = get_ssh_key_pair()
     github_user = Github(username, account_password).get_user()
     public_key = public_key.exportKey('OpenSSH')
     create_key_return = github_user.create_key('willBeDuplicatedAlias', public_key)
     try:
         github_user.create_key('willBeDuplicatedAlias', public_key)
     except Exception as exception:
         self.assertIsInstance(exception, GithubException)
         self.assertEqual(exception.data['errors'][0]['message'], 'key is already in use')
     github_user.get_key(create_key_return.id).delete()
Example #4
0
 def test_throws_exception_when_key_is_duplicate(self):
     _, public_key = get_ssh_key_pair()
     github_user = Github(username, account_password).get_user()
     public_key = public_key.exportKey('OpenSSH')
     create_key_return = github_user.create_key('willBeDuplicatedAlias',
                                                public_key)
     try:
         github_user.create_key('willBeDuplicatedAlias', public_key)
     except Exception as exception:
         self.assertIsInstance(exception, GithubException)
         self.assertEqual(exception.data['errors'][0]['message'],
                          'key is already in use')
     github_user.get_key(create_key_return.id).delete()
 def test_returns_something_when_key_is_created(self):
     _, public_key = get_ssh_key_pair()
     github_user = Github(username, account_password).get_user()
     public_key = public_key.exportKey('OpenSSH')
     create_key_return = github_user.create_key('someTestKeyAlias', public_key)
     self.assertTrue(create_key_return.verified)
     key_id = create_key_return.id
     delete_key_return = github_user.get_key(key_id).delete()
     self.assertTrue(delete_key_return is None)
Example #6
0
 def test_returns_something_when_key_is_created(self):
     _, public_key = get_ssh_key_pair()
     github_user = Github(username, account_password).get_user()
     public_key = public_key.exportKey('OpenSSH')
     create_key_return = github_user.create_key('someTestKeyAlias',
                                                public_key)
     self.assertTrue(create_key_return.verified)
     key_id = create_key_return.id
     delete_key_return = github_user.get_key(key_id).delete()
     self.assertTrue(delete_key_return is None)