def testCheckoutBinaryPackage(self): _, facade = self.prep() mock.mock(facade, '_getVersion') mock.mock(facade, '_getFlavor') mockConaryCfg = mock.MockObject() mockConaryCfg._mock.enable('root') mock.mockMethod(facade.getConaryConfig) facade.getConaryConfig._mock.setDefaultReturn(mockConaryCfg) # Pin callback object callback = conaryfacade._QuietUpdateCallback() self.mock(conaryfacade, '_QuietUpdateCallback', lambda: callback) # quiet savedArgs = [] doUpdateFn = lambda *args, **kwargs: mockedFunction(None, savedArgs, None, *args, **kwargs) self.mock(updatecmd, 'doUpdate', doUpdateFn) facade.checkoutBinaryPackage('packageName', 'packageVersion', 'packageFlavor', 'targetDir') self.assertEquals(mockConaryCfg.root, 'targetDir') self.assertEquals(savedArgs, [ ((mockConaryCfg, 'packageName=packageVersion[packageFlavor]'), {'tagScript': None, 'callback': callback, 'depCheck': False}) ]) # noisy savedArgs = [] facade.checkoutBinaryPackage('packageName', 'packageVersion', 'packageFlavor', 'targetDir', quiet=False) self.assertEquals(savedArgs, [ ((mockConaryCfg, 'packageName=packageVersion[packageFlavor]'), {'tagScript': None, 'callback': None, 'depCheck': False}) ])
def testCheckoutBinaryPackage(self): _, facade = self.prep() mock.mock(facade, '_getVersion') mock.mock(facade, '_getFlavor') mockConaryCfg = mock.MockObject() mockConaryCfg._mock.enable('root') mock.mockMethod(facade.getConaryConfig) facade.getConaryConfig._mock.setDefaultReturn(mockConaryCfg) # Pin callback object callback = conaryfacade._QuietUpdateCallback() self.mock(conaryfacade, '_QuietUpdateCallback', lambda: callback) # quiet savedArgs = [] doUpdateFn = lambda *args, **kwargs: mockedFunction( None, savedArgs, None, *args, **kwargs) self.mock(updatecmd, 'doUpdate', doUpdateFn) facade.checkoutBinaryPackage('packageName', 'packageVersion', 'packageFlavor', 'targetDir') self.assertEquals(mockConaryCfg.root, 'targetDir') self.assertEquals( savedArgs, [((mockConaryCfg, 'packageName=packageVersion[packageFlavor]'), { 'tagScript': None, 'callback': callback, 'depCheck': False })]) # noisy savedArgs = [] facade.checkoutBinaryPackage('packageName', 'packageVersion', 'packageFlavor', 'targetDir', quiet=False) self.assertEquals( savedArgs, [((mockConaryCfg, 'packageName=packageVersion[packageFlavor]'), { 'tagScript': None, 'callback': None, 'depCheck': False })])
def testQuietUpdateCallback(self): callback = conaryfacade._QuietUpdateCallback() callback.setUpdateJob()