def testFileNameProcessing(self):
     rootdir = os.path.abspath('./data/output/filenametests')
     sourcedir = os.path.abspath('./data/sources/filenametests')
     for dirpath, dirnames, filenames in os.walk(rootdir): #@UnusedVariable IGNORE:W0612
         for somefile in filenames:
             filepath = os.path.join(dirpath, somefile)
             os.remove(filepath)
     n = 0
     for dirpath, dirnames, filenames in os.walk(sourcedir): #@UnusedVariable
         for somefile in filenames:
             filepath = os.path.join(dirpath, somefile)
             destpath = os.path.join(rootdir, somefile)
             shutil.copy2(filepath, destpath)
             n += 1
     pw = PluginWizard(CONFIG_ALT)
     pw.set_destdir(rootdir)
     self.assertTrue(len(pw._token_table) > 0)
     pw.process_names(overwrite=True)
     m = 0
     for dirpath, dirnames, filenames in os.walk(rootdir): #@UnusedVariable IGNORE:W0612
         for somefile in filenames:
             # assert that there are no magic token chars left in any one file name
             self.assertTrue(pw.tokenchar_start not in somefile)
             self.assertTrue(pw.tokenchar_end not in somefile)
             self.assertTrue('${' not in somefile)
             m += 1
     self.assertEqual(n, m, 'number of input files should equal number expected output files')
 def testInitialization(self):        
     bogusrootdir = './data/doesnexist'
             
     self.assertRaises(CLIError, PluginWizard, config=CONFIG_BOGUS)
     self.assertRaises(CLIError, PluginWizard(CONFIG_DEFAULT).set_destdir, somepath=bogusrootdir)
     
     rootdir = os.path.abspath('./data/output/filenametests')
     
     pw = PluginWizard(CONFIG_DEFAULT)
     pw.set_destdir(rootdir)
     
     self.assertEqual(os.path.join(CURDIR, 'data', 'sources'), pw.srcdir)
     self.assertEqual(os.path.join(CURDIR, 'data', 'output', 'filenametests'), pw.destdir)
     self.assertEqual(os.path.join(CURDIR, 'data', 'rules.py'), pw._rules_filepath)
     self.assertTrue(len(pw._rules_list) > 0)
 def testFileContentsProcessing(self):
     destdir = os.path.abspath('./data/output/contenttests')
     sourcedir = os.path.abspath('./data/sources/contenttests')
     expectdir = os.path.abspath('./data/expected/contenttests')
     rulesfile = RULESFILE_DEFAULT
     n = 0
     for dirpath, dirnames, filenames in os.walk(sourcedir): #@UnusedVariable IGNORE:W0612
         for somefile in filenames:
             filepath = os.path.join(dirpath, somefile)
             destpath = os.path.join(destdir, somefile)
             shutil.copy2(filepath, destpath)
             n += 1
     config = CONFIG_DEFAULT
     pw = PluginWizard(config)
     pw.set_destdir(destdir)
     pw.process_contents()
     m = 0
     for dirpath, dirnames, filenames in os.walk(destdir): #@UnusedVariable IGNORE:W0612
         for somefile in filenames:
             actual = os.path.join(dirpath, somefile)
             expected = os.path.join(expectdir, somefile)
             self.assertFilesEqual(actual, expected, rulesfile)
             m += 1
     self.assertEqual(n, m, 'number of input files should equal number expected output files')