28 import configuration |
28 import configuration |
29 import logging |
29 import logging |
30 import fileutils |
30 import fileutils |
31 import xml.dom.minidom |
31 import xml.dom.minidom |
32 import tempfile |
32 import tempfile |
33 import test_fileutils |
33 import pythoncorecpythontests.test_fileutils |
34 |
34 |
35 _logger = logging.getLogger('test.archive') |
35 _logger = logging.getLogger('test.archive') |
36 |
36 |
37 |
37 |
38 _root_test_dir = test_fileutils._root_test_dir |
38 root_test_dir = pythoncorecpythontests.test_fileutils.root_test_dir |
39 |
39 |
40 def setup_module(): |
40 def setup_module(): |
41 """ Creates some test data files for file-related testing. """ |
41 """ Creates some test data files for file-related testing. """ |
42 test_fileutils.setup_module() |
42 pythoncorecpythontests.test_fileutils.setup_module() |
43 |
43 |
44 def teardown_module(): |
44 def teardown_module(): |
45 """ Cleans up test data files for file-related testing. """ |
45 """ Cleans up test data files for file-related testing. """ |
46 test_fileutils.teardown_module() |
46 pythoncorecpythontests.test_fileutils.teardown_module() |
47 |
47 |
48 |
48 |
49 class ArchivePreBuilderTest(unittest.TestCase): |
49 class ArchivePreBuilderTest(unittest.TestCase): |
50 """Tests that an archive configuration file successfully creates an Ant exec file.""" |
50 """Tests that an archive configuration file successfully creates an Ant exec file.""" |
51 EXEC_FILE = "archive_create.ant.xml" |
51 EXEC_FILE = "archive_create.ant.xml" |
53 def test_ant_exec(self): |
53 def test_ant_exec(self): |
54 """Tests that an archive configuration file successfully creates an Ant exec file.""" |
54 """Tests that an archive configuration file successfully creates an Ant exec file.""" |
55 builder = configuration.NestedConfigurationBuilder(os.environ['TEST_DATA'] + '/data/archive_test_input.cfg.xml') |
55 builder = configuration.NestedConfigurationBuilder(os.environ['TEST_DATA'] + '/data/archive_test_input.cfg.xml') |
56 archiveConfigSet = builder.getConfiguration() |
56 archiveConfigSet = builder.getConfiguration() |
57 archivePreBuilder = archive.ArchivePreBuilder(archiveConfigSet, "config", index=0) |
57 archivePreBuilder = archive.ArchivePreBuilder(archiveConfigSet, "config", index=0) |
58 buildFilePath = os.path.join(_root_test_dir, r'archive_test.ant.xml') |
58 buildFilePath = os.path.join(root_test_dir, r'archive_test.ant.xml') |
59 archivePreBuilder.write(buildFilePath) |
59 archivePreBuilder.write(buildFilePath) |
60 build_file = open(buildFilePath) |
60 build_file = open(buildFilePath) |
61 build_file_content = build_file.read() |
61 build_file_content = build_file.read() |
62 _logger.debug(build_file_content) |
62 _logger.debug(build_file_content) |
63 resultDoc = amara.parse(build_file_content) |
63 resultDoc = amara.parse(build_file_content) |
78 # self.config = self.archiveConfigSet.getConfigurations()[0] |
78 # self.config = self.archiveConfigSet.getConfigurations()[0] |
79 # self.archivePreBuilder = archive.ArchivePreBuilder(self.archiveConfigSet) |
79 # self.archivePreBuilder = archive.ArchivePreBuilder(self.archiveConfigSet) |
80 |
80 |
81 def test_manifest_files(self): |
81 def test_manifest_files(self): |
82 """ A LogicalArchive can create a correct manifest. """ |
82 """ A LogicalArchive can create a correct manifest. """ |
83 configDict = {'root.dir': _root_test_dir, |
83 configDict = {'root.dir': root_test_dir, |
84 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), |
84 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), |
85 'archives.dir': _root_test_dir, |
85 'archives.dir': root_test_dir, |
86 'name': 'manifest_test', |
86 'name': 'manifest_test', |
87 'include': 'dir1/*.txt', |
87 'include': 'dir1/*.txt', |
88 'archive.tool': '7za' |
88 'archive.tool': '7za' |
89 } |
89 } |
90 config = configuration.Configuration(configDict) |
90 config = configuration.Configuration(configDict) |
92 builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0) |
92 builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0) |
93 builder.build_manifest(config) |
93 builder.build_manifest(config) |
94 |
94 |
95 expectedPaths = [os.path.normpath('dir1/file1.txt')] |
95 expectedPaths = [os.path.normpath('dir1/file1.txt')] |
96 |
96 |
97 includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_includefile.txt') |
97 includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt') |
98 |
98 |
99 with open(includeFilePath) as f_file: |
99 with open(includeFilePath) as f_file: |
100 content = f_file.readlines() |
100 content = f_file.readlines() |
101 print content |
101 print content |
102 print expectedPaths |
102 print expectedPaths |
103 content = [s.strip().lower() for s in content] |
103 content = [s.strip().lower() for s in content] |
104 self.assert_(content == expectedPaths) |
104 self.assert_(content == expectedPaths) |
105 |
105 |
106 def test_empty_manifest_file(self): |
106 def test_empty_manifest_file(self): |
107 """ A LogicalArchive can handle empty manifest. """ |
107 """ A LogicalArchive can handle empty manifest. """ |
108 configDict = {'root.dir': _root_test_dir, |
108 configDict = {'root.dir': root_test_dir, |
109 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), |
109 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), |
110 'archives.dir': _root_test_dir, |
110 'archives.dir': root_test_dir, |
111 'name': 'manifest_test', |
111 'name': 'manifest_test', |
112 'include': 'nothing', |
112 'include': 'nothing', |
113 'archive.tool': '7za' |
113 'archive.tool': '7za' |
114 } |
114 } |
115 config = configuration.Configuration(configDict) |
115 config = configuration.Configuration(configDict) |
117 builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0) |
117 builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0) |
118 builder.build_manifest(config) |
118 builder.build_manifest(config) |
119 |
119 |
120 expectedPaths = [] |
120 expectedPaths = [] |
121 |
121 |
122 includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_includefile.txt') |
122 includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt') |
123 |
123 |
124 with open(includeFilePath) as f_file: |
124 with open(includeFilePath) as f_file: |
125 content = f_file.readlines() |
125 content = f_file.readlines() |
126 print content |
126 print content |
127 print expectedPaths |
127 print expectedPaths |
128 content = [s_1.strip().lower() for s_1 in content] |
128 content = [s_1.strip().lower() for s_1 in content] |
129 self.assert_(content == expectedPaths) |
129 self.assert_(content == expectedPaths) |
130 |
130 |
131 def test_manifest_files_with_exclude_list(self): |
131 def test_manifest_files_with_exclude_list(self): |
132 """ A LogicalArchive can create a correct manifest. """ |
132 """ A LogicalArchive can create a correct manifest. """ |
133 excludelst = os.path.join(_root_test_dir, 'exclude.lst') |
133 excludelst = os.path.join(root_test_dir, 'exclude.lst') |
134 flh = open(excludelst, 'w+') |
134 flh = open(excludelst, 'w+') |
135 flh.write("/epoc32/tools/variant/variant.cfg\n") |
135 flh.write("/epoc32/tools/variant/variant.cfg\n") |
136 flh.write("\\epoc32\\tools\\abld.pl\n") |
136 flh.write("\\epoc32\\tools\\abld.pl\n") |
137 flh.write(os.path.join(_root_test_dir, 'dir1', 'file1.txt') + "\n") |
137 flh.write(os.path.join(root_test_dir, 'dir1', 'file1.txt') + "\n") |
138 flh.write(os.path.join(_root_test_dir, 'dir1/subdir1/subdir1_file.txt') + "\n") |
138 flh.write(os.path.join(root_test_dir, 'dir1/subdir1/subdir1_file.txt') + "\n") |
139 flh.close() |
139 flh.close() |
140 configDict = {'root.dir': _root_test_dir, |
140 configDict = {'root.dir': root_test_dir, |
141 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), |
141 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), |
142 'archives.dir': _root_test_dir, |
142 'archives.dir': root_test_dir, |
143 'name': 'manifest_test', |
143 'name': 'manifest_test', |
144 'include': 'dir1/**', |
144 'include': 'dir1/**', |
145 'exclude.lst': excludelst, |
145 'exclude.lst': excludelst, |
146 'archive.tool': '7za' |
146 'archive.tool': '7za' |
147 } |
147 } |
155 os.path.normpath('dir1/subdir2/subdir2_file_no_extension'), |
155 os.path.normpath('dir1/subdir2/subdir2_file_no_extension'), |
156 os.path.normpath('dir1/subdir3/'), |
156 os.path.normpath('dir1/subdir3/'), |
157 ] |
157 ] |
158 expectedPaths.sort() |
158 expectedPaths.sort() |
159 |
159 |
160 includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_includefile.txt') |
160 includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt') |
161 |
161 |
162 with open(includeFilePath) as f_file: |
162 with open(includeFilePath) as f_file: |
163 content = f_file.readlines() |
163 content = f_file.readlines() |
164 print content |
164 print content |
165 print expectedPaths |
165 print expectedPaths |
167 content.sort() |
167 content.sort() |
168 self.assert_(content == expectedPaths) |
168 self.assert_(content == expectedPaths) |
169 |
169 |
170 def test_manifestfiles_wth_xcld_lst_abs_ndrv(self): |
170 def test_manifestfiles_wth_xcld_lst_abs_ndrv(self): |
171 """ A LogicalArchive can create a correct manifest with external list and drive. """ |
171 """ A LogicalArchive can create a correct manifest with external list and drive. """ |
172 rtd = os.path.splitdrive(os.path.abspath(_root_test_dir))[1] |
172 rtd = os.path.splitdrive(os.path.abspath(root_test_dir))[1] |
173 excludelst = os.path.join(_root_test_dir, 'exclude.lst') |
173 excludelst = os.path.join(root_test_dir, 'exclude.lst') |
174 flh = open(excludelst, 'w+') |
174 flh = open(excludelst, 'w+') |
175 flh.write("/epoc32/tools/variant/variant.cfg\n") |
175 flh.write("/epoc32/tools/variant/variant.cfg\n") |
176 flh.write("\\epoc32\\tools\\abld.pl\n") |
176 flh.write("\\epoc32\\tools\\abld.pl\n") |
177 flh.write(os.path.join(rtd, 'dir1', 'file1.txt') + "\n") |
177 flh.write(os.path.join(rtd, 'dir1', 'file1.txt') + "\n") |
178 flh.write(os.path.join(rtd, 'dir1/subdir1/subdir1_file.txt') + "\n") |
178 flh.write(os.path.join(rtd, 'dir1/subdir1/subdir1_file.txt') + "\n") |
179 flh.close() |
179 flh.close() |
180 configDict = {'root.dir': os.path.abspath(_root_test_dir), |
180 configDict = {'root.dir': os.path.abspath(root_test_dir), |
181 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), |
181 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), |
182 'archives.dir': _root_test_dir, |
182 'archives.dir': root_test_dir, |
183 'name': 'manifest_test', |
183 'name': 'manifest_test', |
184 'include': 'dir1/**', |
184 'include': 'dir1/**', |
185 'exclude.lst': excludelst, |
185 'exclude.lst': excludelst, |
186 'archive.tool': '7za' |
186 'archive.tool': '7za' |
187 } |
187 } |
195 os.path.normpath('dir1/subdir2/subdir2_file_no_extension'), |
195 os.path.normpath('dir1/subdir2/subdir2_file_no_extension'), |
196 os.path.normpath('dir1/subdir3/'), |
196 os.path.normpath('dir1/subdir3/'), |
197 ] |
197 ] |
198 expectedPaths.sort() |
198 expectedPaths.sort() |
199 |
199 |
200 includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_includefile.txt') |
200 includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt') |
201 |
201 |
202 with open(includeFilePath) as f_file: |
202 with open(includeFilePath) as f_file: |
203 content = f_file.readlines() |
203 content = f_file.readlines() |
204 if os.sep == '\\': |
204 if os.sep == '\\': |
205 content = [s_1.strip().lower() for s_1 in content] |
205 content = [s_1.strip().lower() for s_1 in content] |
241 expected_paths[i] = expected_paths[i].lower() |
241 expected_paths[i] = expected_paths[i].lower() |
242 self.do_distribution_policy_config(expected_paths, policy=archive.mappers.MISSING_POLICY) |
242 self.do_distribution_policy_config(expected_paths, policy=archive.mappers.MISSING_POLICY) |
243 |
243 |
244 def do_distribution_policy_config(self, expected_paths, policy): |
244 def do_distribution_policy_config(self, expected_paths, policy): |
245 """ . """ |
245 """ . """ |
246 configDict = {'root.dir': _root_test_dir, |
246 configDict = {'root.dir': root_test_dir, |
247 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), |
247 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), |
248 'archives.dir': _root_test_dir, |
248 'archives.dir': root_test_dir, |
249 'name': 's60_policy_test', |
249 'name': 's60_policy_test', |
250 'include': 's60/', |
250 'include': 's60/', |
251 'distribution.policy.s60': policy, |
251 'distribution.policy.s60': policy, |
252 'selectors': 'policy', |
252 'selectors': 'policy', |
253 'archive.tool': '7za' |
253 'archive.tool': '7za' |
254 } |
254 } |
255 config = configuration.Configuration(configDict) |
255 config = configuration.Configuration(configDict) |
256 |
256 |
257 builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0) |
257 builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0) |
258 builder.build_manifest(config) |
258 builder.build_manifest(config) |
259 includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_test_includefile.txt') |
259 includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_test_includefile.txt') |
260 |
260 |
261 with open(includeFilePath) as f_file: |
261 with open(includeFilePath) as f_file: |
262 content = f_file.readlines() |
262 content = f_file.readlines() |
263 if os.sep == '\\': |
263 if os.sep == '\\': |
264 content = [s.strip().lower() for s in content] |
264 content = [s.strip().lower() for s in content] |
275 print expected_paths |
275 print expected_paths |
276 assert content == expected_paths |
276 assert content == expected_paths |
277 |
277 |
278 def test_split_manifest_file_unicode(self): |
278 def test_split_manifest_file_unicode(self): |
279 """ A LogicalArchive can split a manifest correctly. """ |
279 """ A LogicalArchive can split a manifest correctly. """ |
280 configDict = {'root.dir': os.path.abspath(_root_test_dir), |
280 configDict = {'root.dir': os.path.abspath(root_test_dir), |
281 'temp.build.dir': os.path.abspath(os.path.join(_root_test_dir, 'temp_build_files')), |
281 'temp.build.dir': os.path.abspath(os.path.join(root_test_dir, 'temp_build_files')), |
282 'archives.dir': os.path.abspath(_root_test_dir), |
282 'archives.dir': os.path.abspath(root_test_dir), |
283 'name': 'manifest_test_unicode', |
283 'name': 'manifest_test_unicode', |
284 'max.files.per.archive': '1', |
284 'max.files.per.archive': '1', |
285 'include': 'test_unicode/', |
285 'include': 'test_unicode/', |
286 'archive.tool': '7za' |
286 'archive.tool': '7za' |
287 } |
287 } |
289 |
289 |
290 builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0) |
290 builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0) |
291 manifest_file_path = builder.build_manifest(config) |
291 manifest_file_path = builder.build_manifest(config) |
292 builder.manifest_to_commands(config, manifest_file_path) |
292 builder.manifest_to_commands(config, manifest_file_path) |
293 |
293 |
294 includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_unicode_includefile.txt') |
294 includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_includefile.txt') |
295 includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_unicode_part01.txt') |
295 includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_part01.txt') |
296 includeFilePath2 = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_unicode_part02.txt') |
296 includeFilePath2 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_part02.txt') |
297 includeFilePath3 = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_unicode_part03.txt') |
297 includeFilePath3 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_part03.txt') |
298 |
298 |
299 with open(includeFilePath) as f_file: |
299 with open(includeFilePath) as f_file: |
300 content = f_file.readlines() |
300 content = f_file.readlines() |
301 with open(includeFilePath1) as f_file: |
301 with open(includeFilePath1) as f_file: |
302 content1 = f_file.readlines() |
302 content1 = f_file.readlines() |
314 self.assert_(len(content2) == 1) |
314 self.assert_(len(content2) == 1) |
315 self.assert_(len(content3) == 1) |
315 self.assert_(len(content3) == 1) |
316 |
316 |
317 def test_distribution_policy_mapper_config(self): |
317 def test_distribution_policy_mapper_config(self): |
318 """ Testing the policy mapper. """ |
318 """ Testing the policy mapper. """ |
319 configDict = {'root.dir': _root_test_dir, |
319 configDict = {'root.dir': root_test_dir, |
320 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), |
320 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), |
321 'archives.dir': _root_test_dir, |
321 'archives.dir': root_test_dir, |
322 'name': 's60_policy_mapper_test', |
322 'name': 's60_policy_mapper_test', |
323 'include': 's60/', |
323 'include': 's60/', |
324 'archive.tool': '7za', |
324 'archive.tool': '7za', |
325 'policy.zip2zip': 'true', |
325 'policy.zip2zip': 'true', |
326 'mapper': 'policy', |
326 'mapper': 'policy', |
370 's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt', |
370 's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt', |
371 's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'another_subdir' + os.sep + 'to_be_removed_9999.txt'] |
371 's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'another_subdir' + os.sep + 'to_be_removed_9999.txt'] |
372 if os.sep == '\\': |
372 if os.sep == '\\': |
373 for i in range(len(expected_paths9999)): |
373 for i in range(len(expected_paths9999)): |
374 expected_paths9999[i] = expected_paths9999[i].lower() |
374 expected_paths9999[i] = expected_paths9999[i].lower() |
375 includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt') |
375 includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt') |
376 includeFilePath0 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt') |
376 includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt') |
377 includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt') |
377 includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt') |
378 includeFilePath9999 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_9999.txt') |
378 includeFilePath9999 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_9999.txt') |
379 includeFilePathInternal = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test.internal.txt') |
379 includeFilePathInternal = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test.internal.txt') |
380 |
380 |
381 content = self.__read_manifest(includeFilePath) |
381 content = self.__read_manifest(includeFilePath) |
382 expected_paths.sort() |
382 expected_paths.sort() |
383 print "Content" |
383 print "Content" |
384 print content |
384 print content |
406 |
406 |
407 assert os.path.exists(includeFilePathInternal) == True |
407 assert os.path.exists(includeFilePathInternal) == True |
408 print "Commands : ", cmds |
408 print "Commands : ", cmds |
409 assert len(cmds) == 3 |
409 assert len(cmds) == 3 |
410 |
410 |
411 # pylint: disable-msg=C0103 |
411 # pylint: disable=C0103 |
412 |
412 |
413 def test_distribution_policy_mapper_config_no_zip2zip(self): |
413 def test_distribution_policy_mapper_config_no_zip2zip(self): |
414 """ Testing the policy mapper. """ |
414 """ Testing the policy mapper. """ |
415 |
415 |
416 configDict = {'root.dir': _root_test_dir, |
416 configDict = {'root.dir': root_test_dir, |
417 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), |
417 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), |
418 'archives.dir': _root_test_dir, |
418 'archives.dir': root_test_dir, |
419 'name': 's60_policy_mapper_test_noz2z', |
419 'name': 's60_policy_mapper_test_noz2z', |
420 'include': 's60/', |
420 'include': 's60/', |
421 'archive.tool': '7za', |
421 'archive.tool': '7za', |
422 'policy.zip2zip': 'false', |
422 'policy.zip2zip': 'false', |
423 'mapper': 'policy' |
423 'mapper': 'policy' |
468 if os.sep == '\\': |
468 if os.sep == '\\': |
469 for i in range(len(expected_paths9999)): |
469 for i in range(len(expected_paths9999)): |
470 expected_paths9999[i] = expected_paths9999[i].lower() |
470 expected_paths9999[i] = expected_paths9999[i].lower() |
471 |
471 |
472 expected_paths.sort() |
472 expected_paths.sort() |
473 includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt') |
473 includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt') |
474 includeFilePath0 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt') |
474 includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt') |
475 includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt') |
475 includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt') |
476 includeFilePath9999 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_9999.txt') |
476 includeFilePath9999 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_9999.txt') |
477 includeFilePathInternal = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_noz2z.internal.txt') |
477 includeFilePathInternal = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_noz2z.internal.txt') |
478 |
478 |
479 content = self.__read_manifest(includeFilePath) |
479 content = self.__read_manifest(includeFilePath) |
480 expected_paths.sort() |
480 expected_paths.sort() |
481 print content |
481 print content |
482 print expected_paths |
482 print expected_paths |
506 # pylint: enable-msg=C0103 |
506 # pylint: enable-msg=C0103 |
507 |
507 |
508 |
508 |
509 def test_dist_policy_mapper_remover_config(self): |
509 def test_dist_policy_mapper_remover_config(self): |
510 """ Testing the policy remover mapper. """ |
510 """ Testing the policy remover mapper. """ |
511 configDict = {'root.dir': _root_test_dir, |
511 configDict = {'root.dir': root_test_dir, |
512 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), |
512 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), |
513 'archives.dir': _root_test_dir, |
513 'archives.dir': root_test_dir, |
514 'name': 's60_policy_mapper_test', |
514 'name': 's60_policy_mapper_test', |
515 'include': 's60/', |
515 'include': 's60/', |
516 'policy.root.dir': os.path.join(_root_test_dir, 's60'), |
516 'policy.root.dir': os.path.join(root_test_dir, 's60'), |
517 'archive.tool': '7za', |
517 'archive.tool': '7za', |
518 'mapper': 'policy.remover', |
518 'mapper': 'policy.remover', |
519 'policy.zip2zip': 'true', |
519 'policy.zip2zip': 'true', |
520 'policy.csv': os.path.join(os.environ['TEST_DATA'], 'data/distribution.policy.id_status.csv'), |
520 'policy.csv': os.path.join(os.environ['TEST_DATA'], 'data/distribution.policy.id_status.csv'), |
521 } |
521 } |
557 's60' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60'] |
557 's60' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60'] |
558 if os.sep == '\\': |
558 if os.sep == '\\': |
559 for i in range(len(expected_paths1)): |
559 for i in range(len(expected_paths1)): |
560 expected_paths1[i] = expected_paths1[i].lower() |
560 expected_paths1[i] = expected_paths1[i].lower() |
561 expected_paths1.sort() |
561 expected_paths1.sort() |
562 includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt') |
562 includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt') |
563 includeFilePath0 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt') |
563 includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt') |
564 includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt') |
564 includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt') |
565 |
565 |
566 content = self.__read_manifest(includeFilePath) |
566 content = self.__read_manifest(includeFilePath) |
567 expected_paths.sort() |
567 expected_paths.sort() |
568 print content |
568 print content |
569 print expected_paths |
569 print expected_paths |
585 assert len(cmds[3]) == 7 |
585 assert len(cmds[3]) == 7 |
586 |
586 |
587 |
587 |
588 def test_dist_policy_mapper_sf_remvr_config(self): |
588 def test_dist_policy_mapper_sf_remvr_config(self): |
589 """ Testing the policy SFL remover mapper. """ |
589 """ Testing the policy SFL remover mapper. """ |
590 configDict = {'root.dir': _root_test_dir, |
590 configDict = {'root.dir': root_test_dir, |
591 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), |
591 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), |
592 'archives.dir': _root_test_dir, |
592 'archives.dir': root_test_dir, |
593 'name': 'sf_policy_sf_mapper_test', |
593 'name': 'sf_policy_sf_mapper_test', |
594 'include': 'sf/', |
594 'include': 'sf/', |
595 'policy.root.dir': os.path.join(_root_test_dir, 'sf'), |
595 'policy.root.dir': os.path.join(root_test_dir, 'sf'), |
596 'archive.tool': '7za', |
596 'archive.tool': '7za', |
597 'mapper': 'sfl.policy.remover', |
597 'mapper': 'sfl.policy.remover', |
598 'policy.zip2zip': 'false', |
598 'policy.zip2zip': 'false', |
599 'policy.csv': os.path.join(os.environ['TEST_DATA'], 'data/distribution.policy.extended_for_sf.id_status.csv'), |
599 'policy.csv': os.path.join(os.environ['TEST_DATA'], 'data/distribution.policy.extended_for_sf.id_status.csv'), |
600 } |
600 } |
657 'sf' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',] |
657 'sf' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',] |
658 if os.sep == '\\': |
658 if os.sep == '\\': |
659 for i in range(len(expected_paths9)): |
659 for i in range(len(expected_paths9)): |
660 expected_paths9[i] = expected_paths9[i].lower() |
660 expected_paths9[i] = expected_paths9[i].lower() |
661 |
661 |
662 includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_includefile.txt') |
662 includeFilePath = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_includefile.txt') |
663 includeFilePath0 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_0.txt') |
663 includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_0.txt') |
664 includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_1.txt') |
664 includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_1.txt') |
665 includeFilePath3 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_3.txt') |
665 includeFilePath3 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_3.txt') |
666 includeFilePath7 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_7.txt') |
666 includeFilePath7 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_7.txt') |
667 includeFilePath9 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_9999.txt') |
667 includeFilePath9 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_9999.txt') |
668 |
668 |
669 |
669 |
670 content = self.__read_manifest(includeFilePath) |
670 content = self.__read_manifest(includeFilePath) |
671 expected_paths.sort() |
671 expected_paths.sort() |
672 print content |
672 print content |
711 print cmd |
711 print cmd |
712 assert len(cmds[1]) == len(expected_paths)-len(expected_paths3), "Remore must be equal to len(expected_paths) - len(expected_paths3)" |
712 assert len(cmds[1]) == len(expected_paths)-len(expected_paths3), "Remore must be equal to len(expected_paths) - len(expected_paths3)" |
713 |
713 |
714 def test_dist_policy_mapper_epl_remvr_config(self): |
714 def test_dist_policy_mapper_epl_remvr_config(self): |
715 """ Testing the policy EPL remover mapper. """ |
715 """ Testing the policy EPL remover mapper. """ |
716 configDict = {'root.dir': _root_test_dir, |
716 configDict = {'root.dir': root_test_dir, |
717 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), |
717 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), |
718 'archives.dir': _root_test_dir, |
718 'archives.dir': root_test_dir, |
719 'name': 'sf_policy_epl_mapper_test', |
719 'name': 'sf_policy_epl_mapper_test', |
720 'include': 'sf/', |
720 'include': 'sf/', |
721 'policy.root.dir': os.path.join(_root_test_dir, 'sf'), |
721 'policy.root.dir': os.path.join(root_test_dir, 'sf'), |
722 'archive.tool': '7za', |
722 'archive.tool': '7za', |
723 'mapper': 'epl.policy.remover', |
723 'mapper': 'epl.policy.remover', |
724 'policy.zip2zip': 'false', |
724 'policy.zip2zip': 'false', |
725 'policy.csv': os.path.join(os.environ['TEST_DATA'], 'data/distribution.policy.extended_for_sf.id_status.csv'), |
725 'policy.csv': os.path.join(os.environ['TEST_DATA'], 'data/distribution.policy.extended_for_sf.id_status.csv'), |
726 } |
726 } |
783 'sf' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',] |
783 'sf' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',] |
784 if os.sep == '\\': |
784 if os.sep == '\\': |
785 for i in range(len(expected_paths9)): |
785 for i in range(len(expected_paths9)): |
786 expected_paths9[i] = expected_paths9[i].lower() |
786 expected_paths9[i] = expected_paths9[i].lower() |
787 |
787 |
788 includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_includefile.txt') |
788 includeFilePath = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_includefile.txt') |
789 includeFilePath0 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_0.txt') |
789 includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_0.txt') |
790 includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_1.txt') |
790 includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_1.txt') |
791 includeFilePath3 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_3.txt') |
791 includeFilePath3 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_3.txt') |
792 includeFilePath7 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_7.txt') |
792 includeFilePath7 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_7.txt') |
793 includeFilePath9 = os.path.join(_root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_9999.txt') |
793 includeFilePath9 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_9999.txt') |
794 |
794 |
795 |
795 |
796 content = self.__read_manifest(includeFilePath) |
796 content = self.__read_manifest(includeFilePath) |
797 expected_paths.sort() |
797 expected_paths.sort() |
798 print content |
798 print content |
849 return content |
849 return content |
850 |
850 |
851 |
851 |
852 def test_split_manifest_file(self): |
852 def test_split_manifest_file(self): |
853 """ A LogicalArchive can split a manifest correctly. """ |
853 """ A LogicalArchive can split a manifest correctly. """ |
854 configDict = {'root.dir': os.path.abspath(_root_test_dir), |
854 configDict = {'root.dir': os.path.abspath(root_test_dir), |
855 'temp.build.dir': os.path.abspath(os.path.join(_root_test_dir, 'temp_build_files')), |
855 'temp.build.dir': os.path.abspath(os.path.join(root_test_dir, 'temp_build_files')), |
856 'archives.dir': os.path.abspath(_root_test_dir), |
856 'archives.dir': os.path.abspath(root_test_dir), |
857 'name': 'manifest_test', |
857 'name': 'manifest_test', |
858 'max.files.per.archive': '1', |
858 'max.files.per.archive': '1', |
859 'include': 'dir/', |
859 'include': 'dir/', |
860 'exclude': 'dir/emptysubdir3', |
860 'exclude': 'dir/emptysubdir3', |
861 'archive.tool': '7za' |
861 'archive.tool': '7za' |
868 |
868 |
869 expectedPaths = ['dir' + os.sep + 'emptysubdir1','dir' + os.sep + 'emptysubdir2'] |
869 expectedPaths = ['dir' + os.sep + 'emptysubdir1','dir' + os.sep + 'emptysubdir2'] |
870 expectedPaths1 = ['dir' + os.sep + 'emptysubdir1\n'] |
870 expectedPaths1 = ['dir' + os.sep + 'emptysubdir1\n'] |
871 expectedPaths2 = ['dir' + os.sep + 'emptysubdir2\n'] |
871 expectedPaths2 = ['dir' + os.sep + 'emptysubdir2\n'] |
872 |
872 |
873 includeFilePath = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_includefile.txt') |
873 includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt') |
874 includeFilePath1 = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_part01.txt') |
874 includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_part01.txt') |
875 includeFilePath2 = os.path.join(_root_test_dir, 'temp_build_files/manifest_test_part02.txt') |
875 includeFilePath2 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_part02.txt') |
876 |
876 |
877 with open(includeFilePath) as f_file: |
877 with open(includeFilePath) as f_file: |
878 content = f_file.readlines() |
878 content = f_file.readlines() |
879 with open(includeFilePath1) as f_file: |
879 with open(includeFilePath1) as f_file: |
880 content1 = f_file.readlines() |
880 content1 = f_file.readlines() |
893 |
893 |
894 class CheckRootDirValueTest(unittest.TestCase): |
894 class CheckRootDirValueTest(unittest.TestCase): |
895 """test root drive value""" |
895 """test root drive value""" |
896 def test_checkRootDirValue(self): |
896 def test_checkRootDirValue(self): |
897 """ Testing the root drive value. """ |
897 """ Testing the root drive value. """ |
898 configDict = {'root.dir': _root_test_dir, |
898 configDict = {'root.dir': root_test_dir, |
899 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), |
899 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), |
900 'archives.dir': _root_test_dir, |
900 'archives.dir': root_test_dir, |
901 'name': 'regular_path_test', |
901 'name': 'regular_path_test', |
902 'include': 'dir1/*.txt', |
902 'include': 'dir1/*.txt', |
903 'archive.tool': '7za' |
903 'archive.tool': '7za' |
904 } |
904 } |
905 configDictUnc = {'root.dir': "\\\\server\\share\\dir", |
905 configDictUnc = {'root.dir': "\\\\server\\share\\dir", |
906 'temp.build.dir': os.path.join(_root_test_dir, 'temp_build_files'), |
906 'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'), |
907 'archives.dir': _root_test_dir, |
907 'archives.dir': root_test_dir, |
908 'name': 'unc_test', |
908 'name': 'unc_test', |
909 'include': 'dir1/*.txt', |
909 'include': 'dir1/*.txt', |
910 'archive.tool': '7za' |
910 'archive.tool': '7za' |
911 } |
911 } |
912 config = configuration.Configuration(configDict) |
912 config = configuration.Configuration(configDict) |
924 self.assert_(len(roots) == 3) |
924 self.assert_(len(roots) == 3) |
925 self.assert_('\\\\server\\share\\' in roots) |
925 self.assert_('\\\\server\\share\\' in roots) |
926 self.assert_('\\\\server\\share1\\dir\\' in roots) |
926 self.assert_('\\\\server\\share1\\dir\\' in roots) |
927 self.assert_('\\\\server2\\share\\somedir\\' in roots) |
927 self.assert_('\\\\server2\\share\\somedir\\' in roots) |
928 |
928 |
929 class MockedConfigBuilder: |
929 class MockedConfigBuilder(object): |
930 """.""" |
930 """.""" |
931 |
931 |
932 def writeToXML(self, xml_file, configs, parse_xml_file): |
932 def writeToXML(self, xml_file, configs, parse_xml_file): |
933 """writeToXML""" |
933 """writeToXML""" |
934 pass |
934 pass |
963 |
963 |
964 class SevenZipFormatArchiverTest(unittest.TestCase): |
964 class SevenZipFormatArchiverTest(unittest.TestCase): |
965 """ Testing 7z archiver class """ |
965 """ Testing 7z archiver class """ |
966 def test_archive(self): |
966 def test_archive(self): |
967 """ Testing whether the ant file for running 7z is created """ |
967 """ Testing whether the ant file for running 7z is created """ |
968 configDict = {'root.dir': os.path.abspath(_root_test_dir), |
968 configDict = {'root.dir': os.path.abspath(root_test_dir), |
969 'temp.build.dir': os.path.abspath(os.path.join(_root_test_dir, 'temp_build_files')), |
969 'temp.build.dir': os.path.abspath(os.path.join(root_test_dir, 'temp_build_files')), |
970 'archives.dir': os.path.abspath(_root_test_dir), |
970 'archives.dir': os.path.abspath(root_test_dir), |
971 'name': 'manifest_test', |
971 'name': 'manifest_test', |
972 'max.files.per.archive': '1', |
972 'max.files.per.archive': '1', |
973 'include': 'dir/', |
973 'include': 'dir/', |
974 'exclude': 'dir/emptysubdir3', |
974 'exclude': 'dir/emptysubdir3', |
975 'archive.tool': '7z' |
975 'archive.tool': '7z' |
976 } |
976 } |
977 config = configuration.Configuration(configDict) |
977 config = configuration.Configuration(configDict) |
978 builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0) |
978 builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0) |
979 manifest_file_path = builder.build_manifest(config) |
979 manifest_file_path = builder.build_manifest(config) |
980 builder.manifest_to_commands(config, manifest_file_path) |
980 builder.manifest_to_commands(config, manifest_file_path) |
981 tmpfilename = os.path.join(os.path.abspath(_root_test_dir),'test_archive_7z.xml') |
981 tmpfilename = os.path.join(os.path.abspath(root_test_dir),'test_archive_7z.xml') |
982 builder.write(tmpfilename) |
982 builder.write(tmpfilename) |
983 tmpfileh = open(tmpfilename,'r') |
983 tmpfileh = open(tmpfilename,'r') |
984 content = tmpfileh.read() |
984 content = tmpfileh.read() |
985 assert content.find('executable="7z">') != -1 |
985 assert content.find('executable="7z">') != -1 |
986 assert content.find('<arg line="a -mx9') != -1 |
986 assert content.find('<arg line="a -mx9') != -1 |