mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 03:41:08 +00:00
Manual implementation of some status checks
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import github
|
||||
|
||||
import Framework
|
||||
|
||||
class Exceptions( Framework.TestCase ):
|
||||
def testInvalidInput( self ):
|
||||
with self.assertRaises( github.GithubException ) as cm:
|
||||
self.g.get_user().create_key( "Bad key", "xxx" )
|
||||
self.assertEqual( cm.exception.status, 422 )
|
||||
self.assertEqual(
|
||||
cm.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"
|
||||
}
|
||||
)
|
||||
@@ -38,5 +38,6 @@ from UserKey import *
|
||||
|
||||
from PaginatedList import *
|
||||
from Issue33 import *
|
||||
from Exceptions import *
|
||||
|
||||
Framework.main()
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
POST /user/keys {'Authorization': 'Basic login_and_password_removed'} {"key": "xxx", "title": "Bad key"}
|
||||
422
|
||||
[('status', '422 Unprocessable Entity'), ('x-ratelimit-remaining', '4995'), ('content-length', '221'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"73f756ef75655dd74463eb1bf4cfefe1"'), ('date', 'Wed, 30 May 2012 07:00:27 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"message":"Validation Failed","errors":[{"field":"key","resource":"PublicKey","message":"key is invalid. It must begin with 'ssh-rsa' or 'ssh-dss'. Check that you're copying the public half of the key","code":"custom"}]}
|
||||
|
||||
Reference in New Issue
Block a user