mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 19:31:10 +00:00
Test more exceptions
This commit is contained in:
@@ -23,6 +23,7 @@ class Github( object ):
|
||||
None,
|
||||
None
|
||||
)
|
||||
NamedUser.NamedUser._checkStatus( status, data )
|
||||
return NamedUser.NamedUser( self.__requester, data, completed = True )
|
||||
|
||||
def get_organization( self, login ):
|
||||
@@ -32,6 +33,7 @@ class Github( object ):
|
||||
None,
|
||||
None
|
||||
)
|
||||
Organization.Organization._checkStatus( status, data )
|
||||
return Organization.Organization( self.__requester, data, completed = True )
|
||||
|
||||
def get_gist( self, id ):
|
||||
@@ -41,10 +43,12 @@ class Github( object ):
|
||||
None,
|
||||
None
|
||||
)
|
||||
Gist.Gist._checkStatus( status, data )
|
||||
return Gist.Gist( self.__requester, data, completed = True )
|
||||
|
||||
def get_gists( self ):
|
||||
status, headers, data = self.__requester.request( "GET", "https://api.github.com/gists/public", None, None )
|
||||
Gist.Gist._checkStatus( status, data )
|
||||
return PaginatedList.PaginatedList(
|
||||
Gist.Gist,
|
||||
self.__requester,
|
||||
|
||||
@@ -13,14 +13,17 @@ class BasicGithubObject( object ):
|
||||
def _request( self, verb, url, parameters, input ):
|
||||
return self._requester.request( verb, url, parameters, input )
|
||||
|
||||
def _parentUrl( self, url ):
|
||||
@staticmethod
|
||||
def _parentUrl( url ):
|
||||
return "/".join( url.split( "/" )[ : -1 ] )
|
||||
|
||||
def _checkStatus( self, status, data ):
|
||||
@staticmethod
|
||||
def _checkStatus( status, data ):
|
||||
if status >= 400:
|
||||
raise GithubException.GithubException( status, data )
|
||||
|
||||
def _NoneIfNotSet( self, value ):
|
||||
@staticmethod
|
||||
def _NoneIfNotSet( value ):
|
||||
if value is NotSet:
|
||||
return None
|
||||
else:
|
||||
@@ -42,5 +45,6 @@ class GithubObject( BasicGithubObject ):
|
||||
None,
|
||||
None
|
||||
)
|
||||
self._checkStatus( status, data )
|
||||
self._useAttributes( data )
|
||||
self._completed = True
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import GithubObject
|
||||
|
||||
class PaginatedList:
|
||||
def __init__( self, contentClass, requester, headers, data ):
|
||||
self.__requester = requester
|
||||
@@ -49,6 +51,7 @@ class PaginatedList:
|
||||
|
||||
def __fetchNextPage( self ):
|
||||
status, headers, data = self.__requester.request( "GET", self.__nextUrl, None, None )
|
||||
GithubObject.GithubObject._checkStatus( status, data )
|
||||
return self.__appendData( headers, data )
|
||||
|
||||
def __appendData( self, headers, data ):
|
||||
|
||||
+2
-1
@@ -39,7 +39,8 @@ class Requester:
|
||||
|
||||
cnx.close()
|
||||
|
||||
self.rate_limiting = ( int( headers[ "x-ratelimit-remaining" ] ), int( headers[ "x-ratelimit-limit" ] ) )
|
||||
if "x-ratelimit-remaining" in headers and "x-ratelimit-limit" in headers:
|
||||
self.rate_limiting = ( int( headers[ "x-ratelimit-remaining" ] ), int( headers[ "x-ratelimit-limit" ] ) )
|
||||
|
||||
# print verb, url, parameters, input, "==>", status, str( headers )[ :30 ], str( output )[ :30 ]
|
||||
return status, headers, output
|
||||
|
||||
Reference in New Issue
Block a user