diff -r c7c26511138f -r 7c4a911dc066 buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_archive.py --- a/buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_archive.py Wed Jun 16 16:51:40 2010 +0300 +++ b/buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_archive.py Fri Aug 13 14:59:05 2010 +0300 @@ -30,20 +30,20 @@ import fileutils import xml.dom.minidom import tempfile -import test_fileutils +import pythoncorecpythontests.test_fileutils _logger = logging.getLogger('test.archive') -_root_test_dir = test_fileutils._root_test_dir +root_test_dir = pythoncorecpythontests.test_fileutils.root_test_dir def setup_module(): """ Creates some test data files for file-related testing. """ - test_fileutils.setup_module() + pythoncorecpythontests.test_fileutils.setup_module() def teardown_module(): """ Cleans up test data files for file-related testing. """ - test_fileutils.teardown_module() + pythoncorecpythontests.test_fileutils.teardown_module() class ArchivePreBuilderTest(unittest.TestCase): @@ -55,7 +55,7 @@ builder = configuration.NestedConfigurationBuilder(os.environ['TEST_DATA'] + '/data/archive_test_input.cfg.xml') archiveConfigSet = builder.getConfiguration() archivePreBuilder = archive.ArchivePreBuilder(archiveConfigSet, "config", index=0) - buildFilePath = os.path.join(_root_test_dir, r'archive_test.ant.xml') + buildFilePath = os.path.join(root_test_dir, r'archive_test.ant.xml') archivePreBuilder.write(buildFilePath) build_file = open(buildFilePath) build_file_content = build_file.read() @@ -80,9 +80,9 @@ def test_manifest_files(self): """ A LogicalArchive can create a correct manifest. """ - configDict = {'root.dir': _root_test_dir, - 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), - 'archives.dir': _root_test_dir, + configDict = {'root.dir': root_test_dir, + 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), + 'archives.dir': root_test_dir, 'name': 'manifest_test', 'include': 'dir1/*.txt', 'archive.tool': '7za' @@ -94,7 +94,7 @@ expectedPaths = [os.path.normpath('dir1/file1.txt')] - includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_includefile.txt') + includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt') with open(includeFilePath) as f_file: content = f_file.readlines() @@ -105,9 +105,9 @@ def test_empty_manifest_file(self): """ A LogicalArchive can handle empty manifest. """ - configDict = {'root.dir': _root_test_dir, - 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), - 'archives.dir': _root_test_dir, + configDict = {'root.dir': root_test_dir, + 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), + 'archives.dir': root_test_dir, 'name': 'manifest_test', 'include': 'nothing', 'archive.tool': '7za' @@ -119,7 +119,7 @@ expectedPaths = [] - includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_includefile.txt') + includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt') with open(includeFilePath) as f_file: content = f_file.readlines() @@ -130,16 +130,16 @@ def test_manifest_files_with_exclude_list(self): """ A LogicalArchive can create a correct manifest. """ - excludelst = os.path.join(_root_test_dir, 'exclude.lst') + excludelst = os.path.join(root_test_dir, 'exclude.lst') flh = open(excludelst, 'w+') flh.write("/epoc32/tools/variant/variant.cfg\n") flh.write("\\epoc32\\tools\\abld.pl\n") - flh.write(os.path.join(_root_test_dir, 'dir1', 'file1.txt') + "\n") - flh.write(os.path.join(_root_test_dir, 'dir1/subdir1/subdir1_file.txt') + "\n") + flh.write(os.path.join(root_test_dir, 'dir1', 'file1.txt') + "\n") + flh.write(os.path.join(root_test_dir, 'dir1/subdir1/subdir1_file.txt') + "\n") flh.close() - configDict = {'root.dir': _root_test_dir, - 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), - 'archives.dir': _root_test_dir, + configDict = {'root.dir': root_test_dir, + 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), + 'archives.dir': root_test_dir, 'name': 'manifest_test', 'include': 'dir1/**', 'exclude.lst': excludelst, @@ -157,7 +157,7 @@ ] expectedPaths.sort() - includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_includefile.txt') + includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt') with open(includeFilePath) as f_file: content = f_file.readlines() @@ -169,17 +169,17 @@ def test_manifestfiles_wth_xcld_lst_abs_ndrv(self): """ A LogicalArchive can create a correct manifest with external list and drive. """ - rtd = os.path.splitdrive(os.path.abspath(_root_test_dir))[1] - excludelst = os.path.join(_root_test_dir, 'exclude.lst') + rtd = os.path.splitdrive(os.path.abspath(root_test_dir))[1] + excludelst = os.path.join(root_test_dir, 'exclude.lst') flh = open(excludelst, 'w+') flh.write("/epoc32/tools/variant/variant.cfg\n") flh.write("\\epoc32\\tools\\abld.pl\n") flh.write(os.path.join(rtd, 'dir1', 'file1.txt') + "\n") flh.write(os.path.join(rtd, 'dir1/subdir1/subdir1_file.txt') + "\n") flh.close() - configDict = {'root.dir': os.path.abspath(_root_test_dir), - 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), - 'archives.dir': _root_test_dir, + configDict = {'root.dir': os.path.abspath(root_test_dir), + 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), + 'archives.dir': root_test_dir, 'name': 'manifest_test', 'include': 'dir1/**', 'exclude.lst': excludelst, @@ -197,7 +197,7 @@ ] expectedPaths.sort() - includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_includefile.txt') + includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt') with open(includeFilePath) as f_file: content = f_file.readlines() @@ -243,9 +243,9 @@ def do_distribution_policy_config(self, expected_paths, policy): """ . """ - configDict = {'root.dir': _root_test_dir, - 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), - 'archives.dir': _root_test_dir, + configDict = {'root.dir': root_test_dir, + 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), + 'archives.dir': root_test_dir, 'name': 's60_policy_test', 'include': 's60/', 'distribution.policy.s60': policy, @@ -256,7 +256,7 @@ builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0) builder.build_manifest(config) - includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_test_includefile.txt') + includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_test_includefile.txt') with open(includeFilePath) as f_file: content = f_file.readlines() @@ -277,9 +277,9 @@ def test_split_manifest_file_unicode(self): """ A LogicalArchive can split a manifest correctly. """ - configDict = {'root.dir': os.path.abspath(_root_test_dir), - 'temp.build.dir': os.path.abspath(os.path.join(_root_test_dir, 'temp_build_files')), - 'archives.dir': os.path.abspath(_root_test_dir), + configDict = {'root.dir': os.path.abspath(root_test_dir), + 'temp.build.dir': os.path.abspath(os.path.join(root_test_dir, 'temp_build_files')), + 'archives.dir': os.path.abspath(root_test_dir), 'name': 'manifest_test_unicode', 'max.files.per.archive': '1', 'include': 'test_unicode/', @@ -291,10 +291,10 @@ manifest_file_path = builder.build_manifest(config) builder.manifest_to_commands(config, manifest_file_path) - includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_unicode_includefile.txt') - includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_unicode_part01.txt') - includeFilePath2 = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_unicode_part02.txt') - includeFilePath3 = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_unicode_part03.txt') + includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_includefile.txt') + includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_part01.txt') + includeFilePath2 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_part02.txt') + includeFilePath3 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_part03.txt') with open(includeFilePath) as f_file: content = f_file.readlines() @@ -316,9 +316,9 @@ def test_distribution_policy_mapper_config(self): """ Testing the policy mapper. """ - configDict = {'root.dir': _root_test_dir, - 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), - 'archives.dir': _root_test_dir, + configDict = {'root.dir': root_test_dir, + 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), + 'archives.dir': root_test_dir, 'name': 's60_policy_mapper_test', 'include': 's60/', 'archive.tool': '7za', @@ -372,11 +372,11 @@ if os.sep == '\\': for i in range(len(expected_paths9999)): expected_paths9999[i] = expected_paths9999[i].lower() - includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt') - includeFilePath0 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt') - includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt') - includeFilePath9999 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_9999.txt') - includeFilePathInternal = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test.internal.txt') + includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt') + includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt') + includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt') + includeFilePath9999 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_9999.txt') + includeFilePathInternal = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test.internal.txt') content = self.__read_manifest(includeFilePath) expected_paths.sort() @@ -408,14 +408,14 @@ print "Commands : ", cmds assert len(cmds) == 3 -# pylint: disable-msg=C0103 +# pylint: disable=C0103 def test_distribution_policy_mapper_config_no_zip2zip(self): """ Testing the policy mapper. """ - configDict = {'root.dir': _root_test_dir, - 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), - 'archives.dir': _root_test_dir, + configDict = {'root.dir': root_test_dir, + 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), + 'archives.dir': root_test_dir, 'name': 's60_policy_mapper_test_noz2z', 'include': 's60/', 'archive.tool': '7za', @@ -470,11 +470,11 @@ expected_paths9999[i] = expected_paths9999[i].lower() expected_paths.sort() - includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt') - includeFilePath0 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt') - includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt') - includeFilePath9999 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_9999.txt') - includeFilePathInternal = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_noz2z.internal.txt') + includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt') + includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt') + includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt') + includeFilePath9999 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_9999.txt') + includeFilePathInternal = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_noz2z.internal.txt') content = self.__read_manifest(includeFilePath) expected_paths.sort() @@ -508,12 +508,12 @@ def test_dist_policy_mapper_remover_config(self): """ Testing the policy remover mapper. """ - configDict = {'root.dir': _root_test_dir, - 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), - 'archives.dir': _root_test_dir, + configDict = {'root.dir': root_test_dir, + 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), + 'archives.dir': root_test_dir, 'name': 's60_policy_mapper_test', 'include': 's60/', - 'policy.root.dir': os.path.join(_root_test_dir, 's60'), + 'policy.root.dir': os.path.join(root_test_dir, 's60'), 'archive.tool': '7za', 'mapper': 'policy.remover', 'policy.zip2zip': 'true', @@ -559,9 +559,9 @@ for i in range(len(expected_paths1)): expected_paths1[i] = expected_paths1[i].lower() expected_paths1.sort() - includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt') - includeFilePath0 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt') - includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt') + includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt') + includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt') + includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt') content = self.__read_manifest(includeFilePath) expected_paths.sort() @@ -587,12 +587,12 @@ def test_dist_policy_mapper_sf_remvr_config(self): """ Testing the policy SFL remover mapper. """ - configDict = {'root.dir': _root_test_dir, - 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), - 'archives.dir': _root_test_dir, + configDict = {'root.dir': root_test_dir, + 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), + 'archives.dir': root_test_dir, 'name': 'sf_policy_sf_mapper_test', 'include': 'sf/', - 'policy.root.dir': os.path.join(_root_test_dir, 'sf'), + 'policy.root.dir': os.path.join(root_test_dir, 'sf'), 'archive.tool': '7za', 'mapper': 'sfl.policy.remover', 'policy.zip2zip': 'false', @@ -659,12 +659,12 @@ for i in range(len(expected_paths9)): expected_paths9[i] = expected_paths9[i].lower() - includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_includefile.txt') - includeFilePath0 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_0.txt') - includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_1.txt') - includeFilePath3 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_3.txt') - includeFilePath7 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_7.txt') - includeFilePath9 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_9999.txt') + includeFilePath = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_includefile.txt') + includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_0.txt') + includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_1.txt') + includeFilePath3 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_3.txt') + includeFilePath7 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_7.txt') + includeFilePath9 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_9999.txt') content = self.__read_manifest(includeFilePath) @@ -713,12 +713,12 @@ def test_dist_policy_mapper_epl_remvr_config(self): """ Testing the policy EPL remover mapper. """ - configDict = {'root.dir': _root_test_dir, - 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), - 'archives.dir': _root_test_dir, + configDict = {'root.dir': root_test_dir, + 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), + 'archives.dir': root_test_dir, 'name': 'sf_policy_epl_mapper_test', 'include': 'sf/', - 'policy.root.dir': os.path.join(_root_test_dir, 'sf'), + 'policy.root.dir': os.path.join(root_test_dir, 'sf'), 'archive.tool': '7za', 'mapper': 'epl.policy.remover', 'policy.zip2zip': 'false', @@ -785,12 +785,12 @@ for i in range(len(expected_paths9)): expected_paths9[i] = expected_paths9[i].lower() - includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_includefile.txt') - includeFilePath0 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_0.txt') - includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_1.txt') - includeFilePath3 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_3.txt') - includeFilePath7 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_7.txt') - includeFilePath9 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_9999.txt') + includeFilePath = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_includefile.txt') + includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_0.txt') + includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_1.txt') + includeFilePath3 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_3.txt') + includeFilePath7 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_7.txt') + includeFilePath9 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_9999.txt') content = self.__read_manifest(includeFilePath) @@ -851,9 +851,9 @@ def test_split_manifest_file(self): """ A LogicalArchive can split a manifest correctly. """ - configDict = {'root.dir': os.path.abspath(_root_test_dir), - 'temp.build.dir': os.path.abspath(os.path.join(_root_test_dir, 'temp_build_files')), - 'archives.dir': os.path.abspath(_root_test_dir), + configDict = {'root.dir': os.path.abspath(root_test_dir), + 'temp.build.dir': os.path.abspath(os.path.join(root_test_dir, 'temp_build_files')), + 'archives.dir': os.path.abspath(root_test_dir), 'name': 'manifest_test', 'max.files.per.archive': '1', 'include': 'dir/', @@ -870,9 +870,9 @@ expectedPaths1 = ['dir' + os.sep + 'emptysubdir1\n'] expectedPaths2 = ['dir' + os.sep + 'emptysubdir2\n'] - includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_includefile.txt') - includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_part01.txt') - includeFilePath2 = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_part02.txt') + includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt') + includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_part01.txt') + includeFilePath2 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_part02.txt') with open(includeFilePath) as f_file: content = f_file.readlines() @@ -895,16 +895,16 @@ """test root drive value""" def test_checkRootDirValue(self): """ Testing the root drive value. """ - configDict = {'root.dir': _root_test_dir, - 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), - 'archives.dir': _root_test_dir, + configDict = {'root.dir': root_test_dir, + 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), + 'archives.dir': root_test_dir, 'name': 'regular_path_test', 'include': 'dir1/*.txt', 'archive.tool': '7za' } configDictUnc = {'root.dir': "\\\\server\\share\\dir", - 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), - 'archives.dir': _root_test_dir, + 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), + 'archives.dir': root_test_dir, 'name': 'unc_test', 'include': 'dir1/*.txt', 'archive.tool': '7za' @@ -926,7 +926,7 @@ self.assert_('\\\\server\\share1\\dir\\' in roots) self.assert_('\\\\server2\\share\\somedir\\' in roots) -class MockedConfigBuilder: +class MockedConfigBuilder(object): """.""" def writeToXML(self, xml_file, configs, parse_xml_file): @@ -965,9 +965,9 @@ """ Testing 7z archiver class """ def test_archive(self): """ Testing whether the ant file for running 7z is created """ - configDict = {'root.dir': os.path.abspath(_root_test_dir), - 'temp.build.dir': os.path.abspath(os.path.join(_root_test_dir, 'temp_build_files')), - 'archives.dir': os.path.abspath(_root_test_dir), + configDict = {'root.dir': os.path.abspath(root_test_dir), + 'temp.build.dir': os.path.abspath(os.path.join(root_test_dir, 'temp_build_files')), + 'archives.dir': os.path.abspath(root_test_dir), 'name': 'manifest_test', 'max.files.per.archive': '1', 'include': 'dir/', @@ -978,7 +978,7 @@ builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0) manifest_file_path = builder.build_manifest(config) builder.manifest_to_commands(config, manifest_file_path) - tmpfilename = os.path.join(os.path.abspath(_root_test_dir),'test_archive_7z.xml') + tmpfilename = os.path.join(os.path.abspath(root_test_dir),'test_archive_7z.xml') builder.write(tmpfilename) tmpfileh = open(tmpfilename,'r') content = tmpfileh.read()