Restore test coverage

This commit is contained in:
Vincent Jacques
2012-03-19 19:17:26 +01:00
parent 25dbd4053e
commit b226b5b4e2
2 changed files with 26 additions and 0 deletions
+6
View File
@@ -103,4 +103,10 @@ class TestCase( unittest.TestCase ):
p.merge()
self.assertTrue( p.is_merged() )
def testRepositoryCompare( self ):
self.requester.expect.dataRequest( "GET", "/user", None, None ).andReturn( { "login": "xxx" } )
self.requester.expect.dataRequest( "GET", "/repos/xxx/yyy", None, None ).andReturn( { "name": "yyy", "owner": { "login": "xxx" } } )
self.requester.expect.dataRequest( "GET", "/repos/xxx/yyy/compare/foo...bar", None, None ).andReturn( { "gabu": "zomeuh" } )
self.assertEqual( self.g.get_user().get_repo( "yyy" ).compare( "foo", "bar" ), { "gabu": "zomeuh" } )
unittest.main()
@@ -530,6 +530,26 @@ class GithubObjectWithMethodFromCallable( TestCaseWithGithubTestObject ):
self.assertEqual( self.o.myMethod( mock.object, 42 ), 72 )
mock.tearDown()
def myOtherCallable( obj, mock, **kwds ):
return mock.call( **kwds )
class GithubObjectWithMethodFromCallableWithAlternative( TestCaseWithGithubTestObject ):
GithubTestObject = GithubObject(
"GithubTestObject",
BaseUrl( lambda obj: "/test" ),
InternalSimpleAttributes( "a1", "a2" ),
MethodFromCallable( "myMethod", Alternative( Parameters( [ "mock", "x1", "x2" ], [ "x3" ] ), Parameters( [ "mock", "y1" ], [ "y2" ] ) ), myOtherCallable, SimpleTypePolicy( None ) )
)
def testCallMethod( self ):
mock = MockMockMock.Mock( "myOtherCallable" )
mock.expect.call( x1 = 1, x2 = 2, x3 = 3 ).andReturn( 72 )
self.assertEqual( self.o.myMethod( mock.object, 1, 2, 3 ), 72 )
mock.expect.call( x1 = 1, x2 = 2 ).andReturn( 73 )
self.assertEqual( self.o.myMethod( mock.object, 1, 2 ), 73 )
mock.expect.call( y1 = 1 ).andReturn( 42 )
self.assertEqual( self.o.myMethod( mock.object, 1 ), 42 )
mock.tearDown()
class GithubObjectWithSeveralInternalSimpleAttributesAndInternalObjectAttributes( TestCaseWithGithubTestObject ):
ContainedObject = GithubObject(
"ContainedObject",