Fix testGistsAll, improve testEvents

This commit is contained in:
Vincent Jacques
2012-05-05 16:43:13 +02:00
parent bddf2051b5
commit c3dd5cd2f1
7 changed files with 126 additions and 25 deletions
+8 -6
View File
@@ -3,6 +3,7 @@ import GithubObjects.AuthenticatedUser
import GithubObjects.NamedUser
import GithubObjects.Organization
import GithubObjects.Gist
import GithubObjects.PaginatedList
class Github:
def __init__( self, login, password ):
@@ -33,9 +34,10 @@ class Github:
return GithubObjects.Gist.Gist( self.__requester, { "id": id }, lazy = False )
def get_gists( self ):
status, headers, data = self.__requester.request( "GET", "/gists/public", None, None )
return [
GithubObjects.Gist.Gist( self.__requester, attributes, lazy = True )
for attributes
in data
]
status, headers, data = self.__requester.request( "GET", "https://api.github.com/gists/public", None, None )
return GithubObjects.PaginatedList.PaginatedList(
GithubObjects.Gist.Gist,
self.__requester,
headers,
data
)
+36 -3
View File
@@ -238,13 +238,46 @@ class NamedUser( object ):
)
def get_public_events( self ):
pass
status, headers, data = self.__requester.request(
"GET",
str( self.url ) + "/events/public",
None,
None
)
return PaginatedList.PaginatedList(
Event.Event,
self.__requester,
headers,
data
)
def get_public_received_events( self ):
pass
status, headers, data = self.__requester.request(
"GET",
str( self.url ) + "/received_events/public",
None,
None
)
return PaginatedList.PaginatedList(
Event.Event,
self.__requester,
headers,
data
)
def get_received_events( self ):
pass
status, headers, data = self.__requester.request(
"GET",
str( self.url ) + "/received_events",
None,
None
)
return PaginatedList.PaginatedList(
Event.Event,
self.__requester,
headers,
data
)
def get_repo( self, name ):
status, headers, data = self.__requester.request(
+3 -1
View File
@@ -9,6 +9,7 @@ class PaginatedList:
def __init__( self, contentClass, requester, headers, data ):
self.__requester = requester
self.__contentClass = contentClass
self.__pages = 0
self.__fromData( headers, data )
def __iter__( self ):
@@ -27,7 +28,8 @@ class PaginatedList:
def __fromData( self, headers, data ):
links = self.__parseLinkHeader( headers )
if len( data ) > 0 and "next" in links:
if len( data ) > 0 and "next" in links and self.__pages < 9:
self.__pages += 1
self.__nextUrl = links[ "next" ]
else:
self.__nextUrl = None