mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Delete objects
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import unittest
|
||||
import MockMockMock
|
||||
|
||||
from GithubObject import BadGithubObjectException, GithubObject, SimpleScalarAttributes, Editable
|
||||
from GithubObject import BadGithubObjectException, GithubObject, SimpleScalarAttributes, Editable, Deletable
|
||||
|
||||
class GithubObjectTestCase( unittest.TestCase ):
|
||||
def testDuplicatedAttributeInOnePolicy( self ):
|
||||
@@ -28,6 +28,9 @@ class TestCaseWithGithubTestObject( unittest.TestCase ):
|
||||
def expectPatch( self, url, data ):
|
||||
return self.g.expect.rawRequest( "PATCH", url, data )
|
||||
|
||||
def expectDelete( self, url ):
|
||||
return self.g.expect.rawRequest( "DELETE", url )
|
||||
|
||||
class GithubObjectWithOnlySimpleScalarAttributes( TestCaseWithGithubTestObject ):
|
||||
GithubTestObject = GithubObject(
|
||||
"GithubTestObject",
|
||||
@@ -128,4 +131,15 @@ class EditableGithubObject( TestCaseWithGithubTestObject ):
|
||||
self.expectGet( "/test" ).andReturn( {} )
|
||||
self.assertEqual( self.o.a4, None )
|
||||
|
||||
class DeletableGithubObject( TestCaseWithGithubTestObject ):
|
||||
GithubTestObject = GithubObject(
|
||||
"GithubTestObject",
|
||||
SimpleScalarAttributes( "a1", "a2", "a3", "a4" ),
|
||||
Deletable(),
|
||||
)
|
||||
|
||||
def testDelete( self ):
|
||||
self.expectDelete( "/test" )
|
||||
self.o.delete()
|
||||
|
||||
unittest.main()
|
||||
|
||||
@@ -64,6 +64,24 @@ class Editable:
|
||||
def getAttributeDefinitions( self ):
|
||||
yield "edit", Editable.AttributeDefinition( self.__mandatoryParameters, self.__optionalParameters )
|
||||
|
||||
class Deletable:
|
||||
class Deletor:
|
||||
def __init__( self, obj ):
|
||||
self.__obj = obj
|
||||
|
||||
def __call__( self ):
|
||||
self.__obj._github.rawRequest( "DELETE", "/test" )
|
||||
|
||||
class AttributeDefinition:
|
||||
def getValueFromRawValue( self, obj, rawValue ):
|
||||
return rawValue
|
||||
|
||||
def updateAttributes( self, obj ):
|
||||
obj._updateAttributes( { "delete": Deletable.Deletor( obj ) } )
|
||||
|
||||
def getAttributeDefinitions( self ):
|
||||
yield "delete", Deletable.AttributeDefinition()
|
||||
|
||||
def GithubObject( className, *attributePolicies ):
|
||||
attributeDefinitions = dict()
|
||||
for attributePolicy in attributePolicies:
|
||||
|
||||
Reference in New Issue
Block a user