Files
PyGithub/test/Exceptions.py
T
Vincent Jacques b3fce397c0 Restore compatibility with Python 2.6
Remove:
- dict comprehensions
- unittest.TestCase.assertRaises with only one argument
2012-06-01 19:05:02 +01:00

26 lines
984 B
Python

import github
import Framework
class Exceptions( Framework.TestCase ):
def testInvalidInput( self ):
try: # Stay compatible with Python 2.6: do not use self.assertRaises with only one argument
self.g.get_user().create_key( "Bad key", "xxx" )
self.fail( "Should have raised" )
except github.GithubException, exception:
self.assertEqual( exception.status, 422 )
self.assertEqual(
exception.data,
{
"errors": [
{
"code": "custom",
"field": "key",
"message": "key is invalid. It must begin with 'ssh-rsa' or 'ssh-dss'. Check that you're copying the public half of the key",
"resource": "PublicKey"
}
],
"message": "Validation Failed"
}
)