mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 03:41:08 +00:00
Merge branch 'topic/issue_21' into develop
This commit is contained in:
@@ -7,9 +7,10 @@ class TestCase( unittest.TestCase ):
|
||||
def setUp( self ):
|
||||
unittest.TestCase.setUp( self )
|
||||
|
||||
self.g = Github( "login", "password" )
|
||||
|
||||
self.requester = MockMockMock.Mock( "requester" )
|
||||
self.debugFile = MockMockMock.Mock( "debugFile", self.requester )
|
||||
|
||||
self.g = Github( "login", "password", self.debugFile.object )
|
||||
self.g._Github__requester = self.requester.object
|
||||
|
||||
def tearDown( self ):
|
||||
@@ -109,4 +110,9 @@ class TestCase( unittest.TestCase ):
|
||||
self.requester.expect.dataRequest( "GET", "/repos/xxx/yyy/compare/foo...bar", None, None ).andReturn( { "gabu": "zomeuh" } )
|
||||
self.assertEqual( self.g.get_user().get_repo( "yyy" ).compare( "foo", "bar" ), { "gabu": "zomeuh" } )
|
||||
|
||||
def testDebugPrint( self ):
|
||||
self.requester.expect.dataRequest( "GET", "/user", None, None ).andReturn( { "login": "xxx", "unknownAttribute": 42 } )
|
||||
self.debugFile.expect.write( "Missing definition of attribute unknownAttribute in class AuthenticatedUser\n" )
|
||||
self.g.get_user().location
|
||||
|
||||
unittest.main()
|
||||
|
||||
+6
-1
@@ -2,8 +2,9 @@ from Requester import Requester
|
||||
from GithubObjects import *
|
||||
|
||||
class Github:
|
||||
def __init__( self, login, password ):
|
||||
def __init__( self, login, password, debugFile = None ):
|
||||
self.__requester = Requester( login, password )
|
||||
self.__debugFile = debugFile
|
||||
|
||||
def _dataRequest( self, verb, url, parameters, data ):
|
||||
return self.__requester.dataRequest( verb, url, parameters, data )
|
||||
@@ -29,3 +30,7 @@ class Github:
|
||||
for attributes
|
||||
in self._dataRequest( "GET", "/gists/public", None, None )
|
||||
]
|
||||
|
||||
def _printDebug( self, *args ):
|
||||
if self.__debugFile is not None:
|
||||
self.__debugFile.write( " ".join( str( arg ) for arg in args ) + "\n" )
|
||||
|
||||
@@ -84,8 +84,11 @@ def GithubObject( className, *attributePolicies ):
|
||||
|
||||
def _updateAttributes( self, attributes ):
|
||||
for attributeName, attributeValue in attributes.iteritems():
|
||||
attributeDefinition = GithubObject.__attributeDefinitions[ attributeName ]
|
||||
self.__attributes[ attributeName ] = attributeDefinition.getValueFromRawValue( self, attributeValue )
|
||||
try:
|
||||
attributeDefinition = GithubObject.__attributeDefinitions[ attributeName ]
|
||||
self.__attributes[ attributeName ] = attributeDefinition.getValueFromRawValue( self, attributeValue )
|
||||
except KeyError:
|
||||
self._github._printDebug( "Missing definition of attribute", attributeName, "in class", className )
|
||||
|
||||
def _markAsCompleted( self ):
|
||||
for attributeName, attributeDefinition in GithubObject.__attributeDefinitions.iteritems():
|
||||
|
||||
@@ -34,7 +34,7 @@ Repository = GithubObject(
|
||||
"pushed_at", "created_at", "organization",
|
||||
"has_issues", "has_wiki", "has_downloads",
|
||||
# Not documented
|
||||
"mirror_url", "updated_at", "id",
|
||||
"mirror_url", "updated_at", "id", "permissions",
|
||||
),
|
||||
InternalObjectAttribute( "owner", NamedUser ),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user