def testfileInfos(self): Environment.cleanupTestFolder() exampleFile = Environment.setupExamplesDir() myDef = Definition('Name1', 'dir', Environment.examplesFolder(), 'Test/Dir') infos = [] for info in myDef.fileInfos(): infos.append(info) self.assert_(infos <> None, 'No fileInfos created') self.assert_( infos[0]['source'] == os.path.join(Environment.examplesFolder(), 'example.txt'), 'Example source file not OK') self.assert_( infos[0]['target'] == os.path.join('Test/Dir', 'examples', 'example.txt'), 'Example source file not OK') someFiles = Environment.extendExamplesDir() someFiles.append(exampleFile) infos = [] for info in myDef.fileInfos(): infos.append(info) self.assert_(len(infos) == len(someFiles), 'Not all files found') myDef.includeDirPattern = ['subfolder'] infos = [] for info in myDef.fileInfos(): infos.append(info) # Note that I get all files of the base dir, independent if that matches included dirrs! self.assert_(len(infos) == 4, 'Nb of files not OK for include dirs') Environment.cleanupTestFolder()
def testFileInfos_forFile(self): Environment.cleanupTestFolder() exampleFile = Environment.setupExamplesDir() myDef = Definition('Name1', 'file', exampleFile, 'Test/example.txt') infos = [] for info in myDef.fileInfos(): infos.append(info) self.assert_(len(infos) == 1, 'There should be exactly one fileInfo') self.assert_(infos[0]['source'] == exampleFile, 'Source not OK') self.assert_(infos[0]['target'] == 'Test/example.txt', 'Target not OK') Environment.cleanupTestFolder()