diff --git a/github/GithubObject.UnitTest.py b/github/GithubObject.UnitTest.py index 83dee1ce..64c9f419 100644 --- a/github/GithubObject.UnitTest.py +++ b/github/GithubObject.UnitTest.py @@ -326,6 +326,7 @@ class GithubObjectWithElementCreatableExternalListOfObjects( TestCaseWithGithubT self.assertEqual( self.o.create_a3( "nameCreate", 1, 2 ).id, "idCreate" ) def testCreateWithSillyArgument( self ): + self.g.expect._dataRequest.andReturn( None ) with self.assertRaises( TypeError ): self.o.create_a3( foobar = 42 ) diff --git a/github/ObjectCapacities/List.py b/github/ObjectCapacities/List.py index 4483d329..eef9745a 100644 --- a/github/ObjectCapacities/List.py +++ b/github/ObjectCapacities/List.py @@ -17,21 +17,36 @@ class ElementAddable( ListCapacity ): cls._addMethod( "add_to_" + self.safeAttributeName, self.__execute ) def __execute( self, obj, toBeAdded ): - obj._github._statusRequest( "PUT", obj._baseUrl + "/" + self.attributeName + "/" + self.typePolicy.getIdentity( toBeAdded ), None, None ) + obj._github._statusRequest( + "PUT", + obj._baseUrl + "/" + self.attributeName + "/" + self.typePolicy.getIdentity( toBeAdded ), + None, + None + ) class ElementRemovable( ListCapacity ): def apply( self, cls ): cls._addMethod( "remove_from_" + self.safeAttributeName, self.__execute ) def __execute( self, obj, toBeDeleted ): - obj._github._statusRequest( "DELETE", obj._baseUrl + "/" + self.attributeName + "/" + self.typePolicy.getIdentity( toBeDeleted ), None, None ) + obj._github._statusRequest( + "DELETE", + obj._baseUrl + "/" + self.attributeName + "/" + self.typePolicy.getIdentity( toBeDeleted ), + None, + None + ) class ElementHasable( ListCapacity ): def apply( self, cls ): cls._addMethod( "has_in_" + self.safeAttributeName, self.__execute ) def __execute( self, obj, toBeQueried ): - return obj._github._statusRequest( "GET", obj._baseUrl + "/" + self.attributeName + "/" + self.typePolicy.getIdentity( toBeQueried ), None, None ) == 204 + return obj._github._statusRequest( + "GET", + obj._baseUrl + "/" + self.attributeName + "/" + self.typePolicy.getIdentity( toBeQueried ), + None, + None + ) == 204 class ElementCreatable( ListCapacity ): def __init__( self, mandatoryParameters, optionalParameters, attributeModifiers = {} ): @@ -42,8 +57,18 @@ class ElementCreatable( ListCapacity ): cls._addMethod( "create_" + self.singularName, self.__execute ) def __execute( self, obj, *args, **kwds ): - data = self.__argumentsChecker.check( args, kwds ) - return self.typePolicy.createLazy( obj, self.__modifyAttributes( obj, obj._github._dataRequest( "POST", obj._baseUrl + "/" + self.attributeName, None, data ) ) ) + return self.typePolicy.createLazy( + obj, + self.__modifyAttributes( + obj, + obj._github._dataRequest( + "POST", + obj._baseUrl + "/" + self.attributeName, + None, + self.__argumentsChecker.check( args, kwds ) + ) + ) + ) def __modifyAttributes( self, obj, attributes ): for attributeName, attributeModifier in self.__attributeModifiers.iteritems(): @@ -59,7 +84,13 @@ class ElementGetable( ListCapacity ): cls._addMethod( "get_" + self.singularName, self.__execute ) def __execute( self, obj, *args, **kwds ): - return self.typePolicy.createNonLazy( obj, self.__modifyAttributes( obj, self.__argumentsChecker.check( args, kwds ) ) ) + return self.typePolicy.createNonLazy( + obj, + self.__modifyAttributes( + obj, + self.__argumentsChecker.check( args, kwds ) + ) + ) def __modifyAttributes( self, obj, attributes ): for attributeName, attributeModifier in self.__attributeModifiers.iteritems(): @@ -71,14 +102,30 @@ class SeveralElementsAddable( ListCapacity ): cls._addMethod( "add_to_" + self.safeAttributeName, self.__execute ) def __execute( self, obj, *toBeAddeds ): - obj._github._statusRequest( "POST", obj._baseUrl + "/" + self.attributeName, None, [ self.typePolicy.getIdentity( toBeAdded ) for toBeAdded in toBeAddeds ] ) + obj._github._statusRequest( + "POST", + obj._baseUrl + "/" + self.attributeName, + None, + [ + self.typePolicy.getIdentity( toBeAdded ) + for toBeAdded in toBeAddeds + ] + ) class SeveralElementsRemovable( ListCapacity ): def apply( self, cls ): cls._addMethod( "remove_from_" + self.safeAttributeName, self.__execute ) def __execute( self, obj, *toBeDeleteds ): - obj._github._statusRequest( "DELETE", obj._baseUrl + "/" + self.attributeName, None, [ self.typePolicy.getIdentity( toBeDeleted ) for toBeDeleted in toBeDeleteds ] ) + obj._github._statusRequest( + "DELETE", + obj._baseUrl + "/" + self.attributeName, + None, + [ + self.typePolicy.getIdentity( toBeDeleted ) + for toBeDeleted in toBeDeleteds + ] + ) class ListGetable( ListCapacity ): def __init__( self, mandatoryParameters, optionalParameters, attributeModifiers = {} ): @@ -91,8 +138,16 @@ class ListGetable( ListCapacity ): def __execute( self, obj, *args, **kwds ): params = self.__argumentsChecker.check( args, kwds ) return [ - self.typePolicy.createLazy( obj, self.__modifyAttributes( obj, attributes ) ) - for attributes in obj._github._dataRequest( "GET", obj._baseUrl + "/" + self.attributeName, params, None ) + self.typePolicy.createLazy( + obj, + self.__modifyAttributes( obj, attributes ) + ) + for attributes in obj._github._dataRequest( + "GET", + obj._baseUrl + "/" + self.attributeName, + params, + None + ) ] def __modifyAttributes( self, obj, attributes ): @@ -105,14 +160,27 @@ class ListSetable( ListCapacity ): cls._addMethod( "set_" + self.safeAttributeName, self.__execute ) def __execute( self, obj, *toBeSets ): - obj._github._statusRequest( "PUT", obj._baseUrl + "/" + self.attributeName, None, [ self.typePolicy.getIdentity( toBeSet ) for toBeSet in toBeSets ] ) + obj._github._statusRequest( + "PUT", + obj._baseUrl + "/" + self.attributeName, + None, + [ + self.typePolicy.getIdentity( toBeSet ) + for toBeSet in toBeSets + ] + ) class ListDeletable( ListCapacity ): def apply( self, cls ): cls._addMethod( "delete_" + self.safeAttributeName, self.__execute ) def __execute( self, obj ): - obj._github._statusRequest( "DELETE", obj._baseUrl + "/" + self.attributeName, None, None ) + obj._github._statusRequest( + "DELETE", + obj._baseUrl + "/" + self.attributeName, + None, + None + ) def ExternalListOfObjects( attributeName, singularName, type, *capacities ): for capacity in capacities: