diff --git a/github/GithubObject.UnitTest.py b/github/GithubObject.UnitTest.py index 5b79bfcc..597dcd30 100644 --- a/github/GithubObject.UnitTest.py +++ b/github/GithubObject.UnitTest.py @@ -100,5 +100,14 @@ class EditableGithubObject( TestCaseWithGithubTestObject ): self.o.edit( 11, a2 = 22, a4 = 44 ) self.expectPatch( "/test", { "a1": 11, "a2": 22, "a4": 44 } ).andReturn( {} ) self.o.edit( 11, 22, a4 = 44 ) + # - acknowledges updates of attributes + self.expectPatch( "/test", { "a1": 11 } ).andReturn( { "a2": 22, "a3": 3 } ) + self.o.edit( a1 = 11 ) + self.assertEqual( self.o.a1, 1 ) + self.assertEqual( self.o.a2, 22 ) + self.assertEqual( self.o.a3, 3 ) + # # - is completed even after 'edit's + # self.expectGet( "/test" ).andReturn( {} ) + # self.assertEqual( self.o.a4, None ) unittest.main() diff --git a/github/GithubObject.py b/github/GithubObject.py index 30d569af..04cee543 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -43,7 +43,8 @@ class Editable: for argumentName in kwds: if argumentName not in itertools.chain( self.__mandatoryParamters, self.__optionalParameters ): raise TypeError() - self.__obj._github.rawRequest( "PATCH", "/test", kwds ) + attributes = self.__obj._github.rawRequest( "PATCH", "/test", kwds ) + self.__obj._updateAttributes( attributes ) class AttributeDefinition: def __init__( self, mandatoryParamters, optionalParameters ): @@ -76,7 +77,7 @@ def GithubObject( className, *attributePolicies ): def __init__( self, github, attributes, lazy ): self._github = github self.__attributes = dict() - self.__updateAttributes( attributes ) + self._updateAttributes( attributes ) if not lazy: for attributeName in attributeDefinitions: if attributeName not in self.__attributes: @@ -90,7 +91,7 @@ def GithubObject( className, *attributePolicies ): else: raise AttributeError() - def __updateAttributes( self, attributes ): + def _updateAttributes( self, attributes ): for attributeName, attributeValue in attributes.iteritems(): attributeDefinition = attributeDefinitions[ attributeName ] if attributeValue is None: @@ -101,6 +102,6 @@ def GithubObject( className, *attributePolicies ): def __fetchAttribute( self, attributeName ): attributeDefinition = attributeDefinitions[ attributeName ] - self.__updateAttributes( attributeDefinition.fetchRawValues( self ) ) + self._updateAttributes( attributeDefinition.fetchRawValues( self ) ) return GithubObject