class SuccessfulSetupTestCase(unittest.TestCase): """This loads the test.bif data and looks for expected responses.""" def setUp(self): global dataSource self.dataSource = dataSource self.bif = BIF() self.bif.setDataSource(self.dataSource) self.bif.loadData() def testGetBIFVersion(self): """SuccessfulSetupTestCase::getBifVersion()""" assertEquals('BIF Version', self.bif.getBIFVersion(), '1.05') def testGetBuildID(self): """SuccessfulSetupTestCase::getBuildID()""" assertEquals('Build ID', self.bif.getBuildID(), 'test_build_id') def testGetDataAsFormattedString(self): """SuccessfulSetupTestCase::getDataAsFormattedString()""" assertEquals('Formatted string length', len(self.bif.getDataAsFormattedString().split('\n')), 32) def testGetDataAsString(self): """SuccessfulSetupTestCase::getDataAsString()""" assertEquals('Data string length', len(self.bif.getDataAsString().split('\n')), 28) def testGetDataSource(self): """SuccessfulSetupTestCase::getDataSource()""" assertEquals('Data source', self.bif.getDataSource(), self.dataSource) def testGetDefaultCVSDate(self): """SuccessfulSetupTestCase::getDefaultCVSDate()""" assertEquals('Default CVS date', self.bif.getDefaultCVSDate(), '2006-04-05') def testGetDefaultCVSRoot(self): """SuccessfulSetupTestCase::getDefaultCVSRoot()""" assertEquals('Default CVS root', self.bif.getDefaultCVSRoot(), 'test_root') def testGetDefaultCVSTag(self): """SuccessfulSetupTestCase::getDefaultCVSTag()""" assertEquals('Default CVS tag', self.bif.getDefaultCVSTag(), 'test_tag') def testGetDefaultCVSTagType(self): """SuccessfulSetupTestCase::getDefaultCVSTagType()""" assertEquals('Default CVS tag type', self.bif.getDefaultCVSTagType(), 'tag') def testGetDefaultOptions(self): """SuccessfulSetupTestCase::getDefaultOptions()""" assertEquals('Default options', self.bif.getDefaultOptions(), 'test_option') def testGetDefaultProfile(self): """SuccessfulSetupTestCase::getDefaultProfile()""" assertEquals('Default profile', self.bif.getDefaultProfile(), 'test_profile') def testGetDefaults(self): """SuccessfulSetupTestCase::getDefaults()""" assertEquals('Default object list count', len(self.bif.getDefaults()), 1) def testGetDefaultTarget(self): """SuccessfulSetupTestCase::getDefaultTarget()""" assertEquals('Default target', self.bif.getDefaultTarget(), 'test_default_target') def testGetExpiration(self): """SuccessfulSetupTestCase::getExpiration()""" # Invokes a method of the Timestamp class. assertEquals('Expires ticks', self.bif.getExpiration().getLocalTicks(), 1167638400) def testGetModuleName(self): """SuccessfulSetupTestCase::getModuleName()""" assertEquals('Module name', self.bif.getModuleName('module2'), 'test_name') def testGetModules(self): """SuccessfulSetupTestCase::getModules()""" assertEquals('Number of modules', len(self.bif.getModules()), 3) def testSetBuildID(self): """SuccessfulSetupTestCase::setBuildID()""" self.bif.setBuildID('new_id') assertEquals('Setting Build ID', self.bif.getBuildID(), 'new_id') def testSetDefaultCVSRoot(self): """SuccessfulSetupTestCase::setDefaultCVSRoot()""" self.bif.setDefaultCVSRoot('new_root') assertEquals('Setting CVS root', self.bif.getDefaultCVSRoot(), 'new_root') def testSetDefaultCVSTag(self): """SuccessfulSetupTestCase::setDefaultCVSTag()""" self.bif.setDefaultCVSTag('new_tag') assertEquals('Setting CVS tag', self.bif.getDefaultCVSTag(), 'new_tag') def testSetDefaultCVSTagType(self): """SuccessfulSetupTestCase::setDefaultCVSTagType()""" self.bif.setDefaultCVSTagType('branch') assertEquals('Setting CVS type', self.bif.getDefaultCVSTagType(), 'branch') def testAddModule(self): """SuccessfulSetupTestCase::addModule()""" modules = self.bif.getModules() newModule = modules[0] newModule.id = 'new_module' self.bif.addModule(newModule) assertEquals('Number of modules', len(self.bif.getModules()), 4) def testRemoveModule(self): """SuccessfulSetupTestCase::removeModule()""" self.bif.removeModule('module1') assertEquals('Number of modules', len(self.bif.getModules()), 2) def testSaveData(self): """SuccessfulSetupTestCase::saveData()""" tempSource = os.path.join(testRoot, 'test-out.bif') self.bif.setDataSource(tempSource) self.bif.saveData() self.bif.removeModule('module1') assertEquals('Modules in memory', len(self.bif.getModules()), 2) self.bif.loadData() # Only 2 modules in test-out because it is deleting the shadow module. # Is this desired behavior? assertEquals('Modules in test-out.bif', len(self.bif.getModules()), 2)
class SuccessfulSetupTestCase( unittest.TestCase ): """This loads the test.bif data and looks for expected responses.""" def setUp( self ): global dataSource self.dataSource = dataSource self.bif = BIF() self.bif.setDataSource( self.dataSource ) self.bif.loadData() def testGetBIFVersion( self ): """SuccessfulSetupTestCase::getBifVersion()""" assertEquals( 'BIF Version' , self.bif.getBIFVersion() , '1.05' ) def testGetBuildID( self ): """SuccessfulSetupTestCase::getBuildID()""" assertEquals( 'Build ID' , self.bif.getBuildID() , 'test_build_id' ) def testGetDataAsFormattedString( self ): """SuccessfulSetupTestCase::getDataAsFormattedString()""" assertEquals( 'Formatted string length' , len( self.bif.getDataAsFormattedString().split('\n') ) , 32 ) def testGetDataAsString( self ): """SuccessfulSetupTestCase::getDataAsString()""" assertEquals( 'Data string length' , len( self.bif.getDataAsString().split('\n') ) , 28 ) def testGetDataSource( self ): """SuccessfulSetupTestCase::getDataSource()""" assertEquals( 'Data source' , self.bif.getDataSource() , self.dataSource ) def testGetDefaultCVSDate( self ): """SuccessfulSetupTestCase::getDefaultCVSDate()""" assertEquals( 'Default CVS date' , self.bif.getDefaultCVSDate() , '2006-04-05' ) def testGetDefaultCVSRoot( self ): """SuccessfulSetupTestCase::getDefaultCVSRoot()""" assertEquals( 'Default CVS root' , self.bif.getDefaultCVSRoot() , 'test_root' ) def testGetDefaultCVSTag( self ): """SuccessfulSetupTestCase::getDefaultCVSTag()""" assertEquals( 'Default CVS tag' , self.bif.getDefaultCVSTag() , 'test_tag' ) def testGetDefaultCVSTagType( self ): """SuccessfulSetupTestCase::getDefaultCVSTagType()""" assertEquals( 'Default CVS tag type' , self.bif.getDefaultCVSTagType() , 'tag' ) def testGetDefaultOptions( self ): """SuccessfulSetupTestCase::getDefaultOptions()""" assertEquals( 'Default options' , self.bif.getDefaultOptions() , 'test_option' ) def testGetDefaultProfile( self ): """SuccessfulSetupTestCase::getDefaultProfile()""" assertEquals( 'Default profile' , self.bif.getDefaultProfile() , 'test_profile' ) def testGetDefaults( self ): """SuccessfulSetupTestCase::getDefaults()""" assertEquals( 'Default object list count' , len( self.bif.getDefaults() ), 1 ) def testGetDefaultTarget( self ): """SuccessfulSetupTestCase::getDefaultTarget()""" assertEquals( 'Default target' , self.bif.getDefaultTarget() , 'test_default_target' ) def testGetExpiration( self ): """SuccessfulSetupTestCase::getExpiration()""" # Invokes a method of the Timestamp class. assertEquals( 'Expires ticks' , self.bif.getExpiration().getLocalTicks() , 1167638400 ) def testGetModuleName( self ): """SuccessfulSetupTestCase::getModuleName()""" assertEquals( 'Module name' , self.bif.getModuleName( 'module2' ) , 'test_name' ) def testGetModules( self ): """SuccessfulSetupTestCase::getModules()""" assertEquals( 'Number of modules' , len( self.bif.getModules() ), 3 ) def testSetBuildID( self ): """SuccessfulSetupTestCase::setBuildID()""" self.bif.setBuildID( 'new_id' ) assertEquals( 'Setting Build ID' , self.bif.getBuildID() , 'new_id' ) def testSetDefaultCVSRoot( self ): """SuccessfulSetupTestCase::setDefaultCVSRoot()""" self.bif.setDefaultCVSRoot( 'new_root' ) assertEquals( 'Setting CVS root' , self.bif.getDefaultCVSRoot() , 'new_root' ) def testSetDefaultCVSTag( self ): """SuccessfulSetupTestCase::setDefaultCVSTag()""" self.bif.setDefaultCVSTag( 'new_tag' ) assertEquals( 'Setting CVS tag' , self.bif.getDefaultCVSTag() , 'new_tag' ) def testSetDefaultCVSTagType( self ): """SuccessfulSetupTestCase::setDefaultCVSTagType()""" self.bif.setDefaultCVSTagType( 'branch' ) assertEquals( 'Setting CVS type' , self.bif.getDefaultCVSTagType() , 'branch' ) def testAddModule( self ): """SuccessfulSetupTestCase::addModule()""" modules = self.bif.getModules() newModule = modules[ 0 ] newModule.id = 'new_module' self.bif.addModule( newModule ) assertEquals( 'Number of modules' , len( self.bif.getModules() ), 4 ) def testRemoveModule( self ): """SuccessfulSetupTestCase::removeModule()""" self.bif.removeModule( 'module1' ) assertEquals( 'Number of modules' , len( self.bif.getModules() ), 2 ) def testSaveData( self ): """SuccessfulSetupTestCase::saveData()""" tempSource = os.path.join( testRoot , 'test-out.bif' ) self.bif.setDataSource( tempSource ) self.bif.saveData() self.bif.removeModule( 'module1' ) assertEquals( 'Modules in memory' , len( self.bif.getModules() ), 2 ) self.bif.loadData() # Only 2 modules in test-out because it is deleting the shadow module. # Is this desired behavior? assertEquals( 'Modules in test-out.bif' , len( self.bif.getModules() ), 2 )