Add type parameter to get_repos

This commit is contained in:
Vincent Jacques
2012-02-19 10:17:25 +01:00
parent 3c2d7b7d81
commit c700599040
3 changed files with 21 additions and 13 deletions
+9 -4
View File
@@ -22,8 +22,8 @@ class TestCaseWithGithubTestObject( unittest.TestCase ):
self.g.tearDown()
unittest.TestCase.tearDown( self )
def expectDataGet( self, url ):
return self.g.expect._dataRequest( "GET", url, None, None )
def expectDataGet( self, url, arguments = None ):
return self.g.expect._dataRequest( "GET", url, arguments, None )
def expectStatusPut( self, url ):
return self.g.expect._statusRequest( "PUT", url, None, None )
@@ -197,17 +197,22 @@ class GithubObjectWithListOfReferences( TestCaseWithGithubTestObject ):
"GithubTestObject",
BaseUrl( lambda obj: "/test" ),
BasicAttributes( "a1", "a2" ),
ListOfReferences( "a3s", ContainedObject )
ListOfReferences( "a3s", ContainedObject, getParameters = [ "type" ] )
)
def testGetList( self ):
self.expectDataGet( "/test/a3s" ).andReturn( [ { "id": "id1" }, { "id": "id2" }, { "id": "id3" } ] )
self.expectDataGet( "/test/a3s", {} ).andReturn( [ { "id": "id1" }, { "id": "id2" }, { "id": "id3" } ] )
a3s = self.o.get_a3s()
self.assertEqual( len( a3s ), 3 )
self.assertEqual( a3s[ 0 ].id, "id1" )
self.expectDataGet( "/test/a3s/id1" ).andReturn( { "name": "name1" } )
self.assertEqual( a3s[ 0 ].name, "name1" )
def testGetListWithType( self ):
self.expectDataGet( "/test/a3s", { "type": "foobar" } ).andReturn( [ { "id": "id1" }, { "id": "id2" }, { "id": "id3" } ] )
a3s = self.o.get_a3s( "foobar" )
self.assertEqual( len( a3s ), 3 )
class GithubObjectWithListOfObjects( TestCaseWithGithubTestObject ):
ContainedObject = GithubObject(
"ContainedObject",