mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 11:21:16 +00:00
Restore test coverage
This commit is contained in:
@@ -24,7 +24,6 @@ class AttributeFromCallable:
|
||||
|
||||
def autoDocument( self ):
|
||||
return ""
|
||||
return "* `" + self.__name + "`\n"
|
||||
|
||||
### @todo include the ArgumentsChecker
|
||||
class MethodFromCallable:
|
||||
|
||||
@@ -65,18 +65,27 @@ class ElementHasable( ListCapacity ):
|
||||
### @todo `bool` -> bool
|
||||
return "* `has_in_" + self.safeAttributeName + "( " + self.singularName + " )`: `bool`\n * `" + self.singularName + "`: " + self.typePolicy.documentTypeName() + "\n"
|
||||
|
||||
class ElementCreatable( ListCapacity ):
|
||||
def __init__( self, mandatoryParameters, optionalParameters, attributeModifiers = {} ):
|
||||
self.__argumentsChecker = ArgumentsChecker( mandatoryParameters, optionalParameters )
|
||||
class ListCapacityWithModifier( ListCapacity ):
|
||||
def __init__( self, attributeModifiers ):
|
||||
self.__attributeModifiers = attributeModifiers
|
||||
|
||||
def _modifyAttributes( self, obj, attributes ):
|
||||
for attributeName, attributeModifier in self.__attributeModifiers.iteritems():
|
||||
attributes[ attributeName ] = attributeModifier( obj )
|
||||
return attributes
|
||||
|
||||
class ElementCreatable( ListCapacityWithModifier ):
|
||||
def __init__( self, mandatoryParameters, optionalParameters, attributeModifiers = {} ):
|
||||
ListCapacityWithModifier.__init__( self, attributeModifiers )
|
||||
self.__argumentsChecker = ArgumentsChecker( mandatoryParameters, optionalParameters )
|
||||
|
||||
def apply( self, cls ):
|
||||
cls._addMethod( "create_" + self.singularName, self.__execute )
|
||||
|
||||
def __execute( self, obj, *args, **kwds ):
|
||||
return self.typePolicy.createLazy(
|
||||
obj,
|
||||
self.__modifyAttributes(
|
||||
self._modifyAttributes(
|
||||
obj,
|
||||
obj._github._dataRequest(
|
||||
"POST",
|
||||
@@ -87,18 +96,13 @@ class ElementCreatable( ListCapacity ):
|
||||
)
|
||||
)
|
||||
|
||||
def __modifyAttributes( self, obj, attributes ):
|
||||
for attributeName, attributeModifier in self.__attributeModifiers.iteritems():
|
||||
attributes[ attributeName ] = attributeModifier( obj )
|
||||
return attributes
|
||||
|
||||
def autoDocument( self ):
|
||||
return "* `create_" + self.singularName + "(" + self.__argumentsChecker.documentParameters() + ")`: " + self.typePolicy.documentTypeName() + "\n"
|
||||
|
||||
class ElementGetable( ListCapacity ):
|
||||
class ElementGetable( ListCapacityWithModifier ):
|
||||
def __init__( self, mandatoryParameters, optionalParameters, attributeModifiers = {} ):
|
||||
ListCapacityWithModifier.__init__( self, attributeModifiers )
|
||||
self.__argumentsChecker = ArgumentsChecker( mandatoryParameters, optionalParameters )
|
||||
self.__attributeModifiers = attributeModifiers
|
||||
|
||||
def apply( self, cls ):
|
||||
cls._addMethod( "get_" + self.singularName, self.__execute )
|
||||
@@ -106,17 +110,12 @@ class ElementGetable( ListCapacity ):
|
||||
def __execute( self, obj, *args, **kwds ):
|
||||
return self.typePolicy.createNonLazy(
|
||||
obj,
|
||||
self.__modifyAttributes(
|
||||
self._modifyAttributes(
|
||||
obj,
|
||||
self.__argumentsChecker.check( args, kwds )
|
||||
)
|
||||
)
|
||||
|
||||
def __modifyAttributes( self, obj, attributes ):
|
||||
for attributeName, attributeModifier in self.__attributeModifiers.iteritems():
|
||||
attributes[ attributeName ] = attributeModifier( obj )
|
||||
return attributes
|
||||
|
||||
def autoDocument( self ):
|
||||
return "* `get_" + self.singularName + "(" + self.__argumentsChecker.documentParameters() + ")`: " + self.typePolicy.documentTypeName() + "\n"
|
||||
|
||||
@@ -156,10 +155,10 @@ class SeveralElementsRemovable( ListCapacity ):
|
||||
def autoDocument( self ):
|
||||
return "* `remove_from_" + self.safeAttributeName + "( " + self.singularName + ", ... )`\n * `" + self.singularName + "`: " + self.typePolicy.documentTypeName() + "\n"
|
||||
|
||||
class ListGetable( ListCapacity ):
|
||||
class ListGetable( ListCapacityWithModifier ):
|
||||
def __init__( self, mandatoryParameters, optionalParameters, attributeModifiers = {} ):
|
||||
ListCapacityWithModifier.__init__( self, attributeModifiers )
|
||||
self.__argumentsChecker = ArgumentsChecker( mandatoryParameters, optionalParameters )
|
||||
self.__attributeModifiers = attributeModifiers
|
||||
|
||||
def apply( self, cls ):
|
||||
cls._addMethod( "get_" + self.safeAttributeName, self.__execute )
|
||||
@@ -169,7 +168,7 @@ class ListGetable( ListCapacity ):
|
||||
return [
|
||||
self.typePolicy.createLazy(
|
||||
obj,
|
||||
self.__modifyAttributes( obj, attributes )
|
||||
self._modifyAttributes( obj, attributes )
|
||||
)
|
||||
for attributes in obj._github._dataRequest(
|
||||
"GET",
|
||||
@@ -182,11 +181,6 @@ class ListGetable( ListCapacity ):
|
||||
def autoDocument( self ):
|
||||
return "* `get_" + self.safeAttributeName + "(" + self.__argumentsChecker.documentParameters() + ")`: list of " + self.typePolicy.documentTypeName() + "\n"
|
||||
|
||||
def __modifyAttributes( self, obj, attributes ):
|
||||
for attributeName, attributeModifier in self.__attributeModifiers.iteritems():
|
||||
attributes[ attributeName ] = attributeModifier( obj )
|
||||
return attributes
|
||||
|
||||
class ListSetable( ListCapacity ):
|
||||
def apply( self, cls ):
|
||||
cls._addMethod( "set_" + self.safeAttributeName, self.__execute )
|
||||
|
||||
@@ -19,10 +19,7 @@ class ObjectTypePolicy:
|
||||
self.__type = type
|
||||
|
||||
def createLazy( self, obj, attributes ):
|
||||
if isinstance( attributes, self.__type ):
|
||||
return attributes
|
||||
else:
|
||||
return self.__type( obj._github, attributes, lazy = True )
|
||||
return self.__type( obj._github, attributes, lazy = True )
|
||||
|
||||
def createNonLazy( self, obj, attributes ):
|
||||
return self.__type( obj._github, attributes, lazy = False )
|
||||
|
||||
Reference in New Issue
Block a user