0
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
"""
|
|
18 |
Test the configuration
|
|
19 |
"""
|
|
20 |
import unittest
|
|
21 |
import string
|
|
22 |
import sys
|
|
23 |
import os
|
|
24 |
import subprocess
|
|
25 |
import zipfile
|
|
26 |
import shutil
|
3
|
27 |
|
0
|
28 |
from testautomation.base_testcase import BaseTestCase
|
|
29 |
from testautomation.unzip_file import unzip_file
|
|
30 |
from cone.storage.filestorage import FileStorage
|
|
31 |
from cone.storage.zipstorage import ZipStorage
|
|
32 |
from scripttest_common import get_cmd
|
|
33 |
|
|
34 |
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
35 |
|
|
36 |
def abspath(p):
|
|
37 |
return os.path.normpath(os.path.join(ROOT_PATH, p))
|
|
38 |
|
|
39 |
TEST_PROJECT_CPF = abspath("test_project.cpf")
|
|
40 |
TEMP_DIR = abspath("temp/export")
|
|
41 |
EXPORT_TEST_PROJECT = abspath("export_test_project.zip")
|
|
42 |
|
|
43 |
class TestExport(BaseTestCase):
|
|
44 |
|
|
45 |
def setUp(self):
|
|
46 |
self.orig_workdir = os.getcwd()
|
|
47 |
os.chdir(ROOT_PATH)
|
|
48 |
|
|
49 |
def tearDown(self):
|
|
50 |
os.chdir(self.orig_workdir)
|
|
51 |
|
|
52 |
def test_get_help(self):
|
|
53 |
cmd = '%s -h' % get_cmd('export')
|
|
54 |
out = self.run_command(cmd)
|
3
|
55 |
lines = out.split(os.linesep)
|
0
|
56 |
self.assertTrue('Options:' in lines)
|
|
57 |
self.assertTrue(' Export options:' in lines)
|
|
58 |
|
|
59 |
def test_export_project(self):
|
|
60 |
remote = os.path.join(TEMP_DIR, 'test1')
|
|
61 |
self.remove_if_exists(remote)
|
|
62 |
|
|
63 |
self.set_modification_reference_time(TEST_PROJECT_CPF)
|
3
|
64 |
cmd = '%s -p "%s" -c "root4.confml" -r "%s"' % (get_cmd('export'), TEST_PROJECT_CPF, remote)
|
0
|
65 |
out = self.run_command(cmd)
|
|
66 |
#print out
|
3
|
67 |
lines = out.split(os.linesep)
|
0
|
68 |
self.assertTrue('Export root4.confml to %s done!' % remote in lines)
|
|
69 |
|
|
70 |
self.assertEquals(set(os.listdir(remote)),
|
|
71 |
set(["Layer1", "Layer2", "Layer3", "Layer4", ".metadata", "root4.confml"]))
|
|
72 |
def fp(p): # fp = full_path
|
|
73 |
return os.path.join(remote, p)
|
|
74 |
self.assert_exists_and_contains_something(fp("Layer1"))
|
|
75 |
self.assert_exists_and_contains_something(fp("Layer2"))
|
|
76 |
self.assert_exists_and_contains_something(fp("Layer3"))
|
|
77 |
self.assert_exists_and_contains_something(fp("Layer4"))
|
|
78 |
self.assert_exists_and_contains_something(fp("root4.confml"))
|
|
79 |
|
|
80 |
self.assert_not_modified(TEST_PROJECT_CPF)
|
|
81 |
|
|
82 |
def test_export_multiple_configurations(self):
|
|
83 |
remote = os.path.join(TEMP_DIR, 'test2')
|
|
84 |
self.remove_if_exists(remote)
|
|
85 |
|
|
86 |
self.set_modification_reference_time(TEST_PROJECT_CPF)
|
|
87 |
cmd = '%s -p "%s" -c "root2.confml" -c "root3.confml" -c "root5.confml" -r "%s"' % (get_cmd('export'), TEST_PROJECT_CPF, remote)
|
|
88 |
out = self.run_command(cmd)
|
|
89 |
#print out
|
3
|
90 |
lines = out.split(os.linesep)
|
0
|
91 |
self.assertTrue('Export root2.confml to %s done!' % remote in lines)
|
|
92 |
self.assertTrue('Export root3.confml to %s done!' % remote in lines)
|
|
93 |
self.assertTrue('Export root5.confml to %s done!' % remote in lines)
|
|
94 |
|
|
95 |
self.assertEquals(set(os.listdir(remote)),
|
|
96 |
set(["Layer1", "Layer2", "Layer3", "Layer4", "Layer5",
|
|
97 |
".metadata", "root2.confml", "root3.confml", "root5.confml"]))
|
|
98 |
def fp(p): # fp = full_path
|
|
99 |
return os.path.join(remote, p)
|
|
100 |
self.assert_exists_and_contains_something(fp("Layer1"))
|
|
101 |
self.assert_exists_and_contains_something(fp("Layer2"))
|
|
102 |
self.assert_exists_and_contains_something(fp("Layer3"))
|
|
103 |
self.assert_exists_and_contains_something(fp("Layer4"))
|
|
104 |
self.assert_exists_and_contains_something(fp("Layer5"))
|
|
105 |
self.assert_exists_and_contains_something(fp("root2.confml"))
|
|
106 |
self.assert_exists_and_contains_something(fp("root3.confml"))
|
|
107 |
self.assert_exists_and_contains_something(fp("root5.confml"))
|
|
108 |
|
|
109 |
self.assert_not_modified(TEST_PROJECT_CPF)
|
|
110 |
|
|
111 |
def test_export_multiple_configurations_into_cpf(self):
|
|
112 |
remote = os.path.join(TEMP_DIR, 'test3.cpf')
|
|
113 |
self.remove_if_exists(remote)
|
|
114 |
|
|
115 |
self.set_modification_reference_time(TEST_PROJECT_CPF)
|
|
116 |
cmd = '%s -p "%s" -c "root2.confml" -c "root3.confml" -c "root5.confml" -r "%s"' % (get_cmd('export'), TEST_PROJECT_CPF, remote)
|
|
117 |
out = self.run_command(cmd)
|
|
118 |
#print out
|
3
|
119 |
lines = out.split(os.linesep)
|
0
|
120 |
self.assertTrue('Export root2.confml to %s done!' % remote in lines)
|
|
121 |
self.assertTrue('Export root3.confml to %s done!' % remote in lines)
|
|
122 |
self.assertTrue('Export root5.confml to %s done!' % remote in lines)
|
|
123 |
|
|
124 |
self.assert_zip_entry_exists(remote, "root2.confml")
|
|
125 |
self.assert_zip_entry_exists(remote, "root3.confml")
|
|
126 |
self.assert_zip_entry_exists(remote, "root5.confml")
|
|
127 |
|
|
128 |
self.assert_not_modified(TEST_PROJECT_CPF)
|
|
129 |
|
|
130 |
def assert_zip_entry_exists(self, zip_file, path):
|
|
131 |
zf = zipfile.ZipFile(zip_file, "r")
|
|
132 |
try:
|
|
133 |
if path not in zf.namelist():
|
|
134 |
self.fail("Entry '%s' not in zip file '%s'." % (path, zipfile))
|
|
135 |
finally:
|
|
136 |
zf.close()
|
5
|
137 |
|
|
138 |
def assert_zip_entry_exists_not(self, zip_file, path):
|
|
139 |
zf = zipfile.ZipFile(zip_file, "r")
|
|
140 |
try:
|
|
141 |
if path in zf.namelist():
|
|
142 |
self.fail("Entry '%s' in zip file '%s'." % (path, zipfile))
|
|
143 |
finally:
|
|
144 |
zf.close()
|
0
|
145 |
|
|
146 |
|
|
147 |
def _run_test_export_project_to_project(self,
|
|
148 |
source_project, source_storage_type,
|
|
149 |
target_project, target_storage_type,
|
|
150 |
empty_folders):
|
|
151 |
# Set up the source project
|
|
152 |
# -------------------------
|
|
153 |
source_path = os.path.join(TEMP_DIR, source_project)
|
|
154 |
self.remove_if_exists(source_path)
|
|
155 |
if source_storage_type == 'file':
|
|
156 |
unzip_file(EXPORT_TEST_PROJECT, source_path, delete_if_exists=True)
|
|
157 |
elif source_storage_type == 'zip':
|
|
158 |
self.create_dir_for_file_path(source_path)
|
|
159 |
shutil.copy2(EXPORT_TEST_PROJECT, source_path)
|
|
160 |
else:
|
|
161 |
raise RuntimeError('Invalid storage type %r' % source_storage_type)
|
|
162 |
|
|
163 |
# Set up the target project
|
|
164 |
# -------------------------
|
|
165 |
target_path = os.path.join(TEMP_DIR, target_project)
|
|
166 |
self.remove_if_exists(target_path)
|
|
167 |
if target_storage_type not in ('file', 'zip'):
|
|
168 |
raise RuntimeError('Invalid storage type %r' % target_storage_type)
|
|
169 |
|
|
170 |
# Run the command
|
|
171 |
# ---------------
|
|
172 |
if empty_folders: empty_folder_switch = ''
|
|
173 |
else: empty_folder_switch = '--exclude-folders'
|
|
174 |
cmd = '%s -p "%s" -c "root5.confml" -r "%s" %s' % \
|
|
175 |
(get_cmd('export'), source_path, target_path, empty_folder_switch)
|
|
176 |
out = self.run_command(cmd)
|
|
177 |
|
|
178 |
# Check the output
|
|
179 |
# ----------------
|
|
180 |
if target_storage_type == 'file': storage_class = FileStorage
|
|
181 |
elif target_storage_type == 'zip': storage_class = ZipStorage
|
|
182 |
|
|
183 |
storage = storage_class(target_path, 'r')
|
|
184 |
res_list = storage.list_resources("/", recurse=True, empty_folders=True)
|
|
185 |
|
|
186 |
expected = ['.metadata',
|
|
187 |
'root5.confml',
|
|
188 |
'Layer1/root.confml',
|
|
189 |
'Layer2/root.confml',
|
|
190 |
'Layer3/root.confml',
|
|
191 |
'Layer4/root.confml',
|
|
192 |
'Layer5/root.confml',]
|
|
193 |
for res in expected:
|
|
194 |
self.assertTrue(res in res_list, "%r not in %r" % (res, res_list))
|
|
195 |
self.assertFalse(storage.is_folder(res), "%r is a folder")
|
|
196 |
|
|
197 |
not_expected = ['Layer1/foo/foo.txt',
|
|
198 |
'Layer2/foo/layer2_foo.txt',
|
|
199 |
'Layer3/foo/layer3_foo.txt',
|
|
200 |
'Layer4/foo/layer4_foo.txt',
|
|
201 |
'Layer5/foo/layer5_foo.txt',]
|
|
202 |
for res in not_expected:
|
|
203 |
self.assertFalse(res in res_list, "%r in %r" % (res, res_list))
|
|
204 |
|
|
205 |
# Check empty folders
|
|
206 |
expected = ['Layer1/doc/empty',
|
|
207 |
'Layer1/content/empty',
|
|
208 |
'Layer1/implml/empty',
|
|
209 |
'Layer3/doc/empty',
|
|
210 |
'Layer3/content/empty',
|
|
211 |
'Layer3/implml/empty',]
|
|
212 |
not_expected = ['Layer1/foo/empty',
|
|
213 |
'Layer3/foo/empty']
|
|
214 |
if empty_folders:
|
|
215 |
for res in expected:
|
|
216 |
self.assertTrue(res in res_list, "%r not in %r" % (res, res_list))
|
|
217 |
self.assertTrue(storage.is_folder(res), "%r is not a folder")
|
|
218 |
|
|
219 |
for res in not_expected:
|
|
220 |
self.assertFalse(res in res_list, "%r in %r" % (res, res_list))
|
|
221 |
else:
|
|
222 |
for res in expected + not_expected:
|
|
223 |
self.assertFalse(res in res_list, "%r in %r" % (res, res_list))
|
|
224 |
|
|
225 |
|
|
226 |
def test_export_file_to_file(self):
|
|
227 |
self._run_test_export_project_to_project(
|
|
228 |
source_project = 'f2f/source',
|
|
229 |
source_storage_type = 'file',
|
|
230 |
target_project = 'f2f/target',
|
|
231 |
target_storage_type = 'file',
|
|
232 |
empty_folders = False)
|
|
233 |
|
|
234 |
self._run_test_export_project_to_project(
|
|
235 |
source_project = 'f2f/source_ef',
|
|
236 |
source_storage_type = 'file',
|
|
237 |
target_project = 'f2f/target_ef',
|
|
238 |
target_storage_type = 'file',
|
|
239 |
empty_folders = True)
|
|
240 |
|
|
241 |
def test_export_zip_to_zip(self):
|
|
242 |
self._run_test_export_project_to_project(
|
|
243 |
source_project = 'z2z/source.zip',
|
|
244 |
source_storage_type = 'zip',
|
|
245 |
target_project = 'z2z/target.zip',
|
|
246 |
target_storage_type = 'zip',
|
|
247 |
empty_folders = False)
|
|
248 |
|
|
249 |
self._run_test_export_project_to_project(
|
|
250 |
source_project = 'z2z/source_ef.zip',
|
|
251 |
source_storage_type = 'zip',
|
|
252 |
target_project = 'z2z/target_ef.zip',
|
|
253 |
target_storage_type = 'zip',
|
|
254 |
empty_folders = True)
|
|
255 |
|
|
256 |
def test_export_file_to_zip(self):
|
|
257 |
self._run_test_export_project_to_project(
|
|
258 |
source_project = 'f2z/source',
|
|
259 |
source_storage_type = 'file',
|
|
260 |
target_project = 'f2z/target.zip',
|
|
261 |
target_storage_type = 'zip',
|
|
262 |
empty_folders = False)
|
|
263 |
|
|
264 |
self._run_test_export_project_to_project(
|
|
265 |
source_project = 'f2z/source_ef',
|
|
266 |
source_storage_type = 'file',
|
|
267 |
target_project = 'f2z/target_ef.zip',
|
|
268 |
target_storage_type = 'zip',
|
|
269 |
empty_folders = True)
|
|
270 |
|
|
271 |
def test_export_zip_to_file(self):
|
|
272 |
self._run_test_export_project_to_project(
|
|
273 |
source_project = 'z2f/source.zip',
|
|
274 |
source_storage_type = 'zip',
|
|
275 |
target_project = 'z2f/target',
|
|
276 |
target_storage_type = 'file',
|
|
277 |
empty_folders = False)
|
|
278 |
|
|
279 |
self._run_test_export_project_to_project(
|
|
280 |
source_project = 'z2f/source_ef.zip',
|
|
281 |
source_storage_type = 'zip',
|
|
282 |
target_project = 'z2f/target_ef',
|
|
283 |
target_storage_type = 'file',
|
|
284 |
empty_folders = True)
|
|
285 |
|
3
|
286 |
def test_export_to_target_with_nonexistent_path(self):
|
|
287 |
# Remove the target root directory to make sure that it
|
|
288 |
# does not exist before the export
|
|
289 |
self.remove_if_exists(os.path.join(TEMP_DIR, 'nep'))
|
|
290 |
|
|
291 |
self._run_test_export_project_to_project(
|
|
292 |
source_project = 'f2z/source',
|
|
293 |
source_storage_type = 'file',
|
|
294 |
target_project = 'nep/f2z/x/y/z/target.zip',
|
|
295 |
target_storage_type = 'zip',
|
|
296 |
empty_folders = False)
|
|
297 |
|
|
298 |
self._run_test_export_project_to_project(
|
|
299 |
source_project = 'f2z/source',
|
|
300 |
source_storage_type = 'file',
|
|
301 |
target_project = 'nep/f2f/x/y/z/target',
|
|
302 |
target_storage_type = 'file',
|
|
303 |
empty_folders = False)
|
|
304 |
|
0
|
305 |
def _run_test_multi_export(self, export_dir, export_format, config_args,
|
|
306 |
expected_cpfs=None, expected_dirs=None):
|
3
|
307 |
self.assertFalse(expected_cpfs is not None and expected_dirs is not None,
|
0
|
308 |
"Only one of expected_cpfs or expected_dirs can be specified!")
|
|
309 |
self.assertFalse(expected_cpfs is None and expected_dirs is None,
|
|
310 |
"Either expected_cpfs or expected_dirs must be specified!")
|
|
311 |
|
|
312 |
EXPORT_DIR = os.path.join(TEMP_DIR, export_dir)
|
|
313 |
self.remove_if_exists(EXPORT_DIR)
|
|
314 |
|
|
315 |
self.set_modification_reference_time(TEST_PROJECT_CPF)
|
|
316 |
cmd = '%(cmd)s -p "%(project)s" %(args)s --export-dir "%(export_dir)s" --export-format %(export_format)s' \
|
|
317 |
% {'cmd' : get_cmd('export'),
|
|
318 |
'project' : TEST_PROJECT_CPF,
|
|
319 |
'args' : config_args,
|
|
320 |
'export_dir' : EXPORT_DIR,
|
|
321 |
'export_format' : export_format}
|
|
322 |
out = self.run_command(cmd)
|
|
323 |
self.assert_not_modified(TEST_PROJECT_CPF)
|
|
324 |
|
|
325 |
if expected_cpfs:
|
|
326 |
for cpf_name, config_root in expected_cpfs:
|
|
327 |
path = os.path.join(EXPORT_DIR, cpf_name)
|
|
328 |
self.assert_exists_and_contains_something(path)
|
|
329 |
self.assert_zip_entry_exists(path, config_root)
|
|
330 |
else:
|
|
331 |
for dir_name, config_root in expected_dirs:
|
|
332 |
path = os.path.join(EXPORT_DIR, dir_name)
|
|
333 |
self.assert_exists_and_contains_something(path)
|
|
334 |
self.assert_exists_and_contains_something(os.path.join(path, config_root))
|
|
335 |
|
|
336 |
def test_export_multiple_cpfs(self):
|
|
337 |
self._run_test_multi_export(
|
|
338 |
export_dir = 'multiexport/cpfs',
|
|
339 |
export_format = 'cpf',
|
|
340 |
config_args = '--configuration root1.confml '\
|
|
341 |
'--configuration root3.confml',
|
|
342 |
expected_cpfs = [('root1.cpf', 'root1.confml'),
|
|
343 |
('root3.cpf', 'root3.confml')])
|
|
344 |
|
|
345 |
def test_export_multiple_dirs(self):
|
|
346 |
self._run_test_multi_export(
|
|
347 |
export_dir = 'multiexport/dirs',
|
|
348 |
export_format = 'dir',
|
|
349 |
config_args = '--configuration root1.confml '\
|
|
350 |
'--configuration root3.confml',
|
|
351 |
expected_dirs = [('root1/', 'root1.confml'),
|
|
352 |
('root3/', 'root3.confml')])
|
|
353 |
|
|
354 |
def test_export_multiple_dirs_with_added_layers(self):
|
|
355 |
self._run_test_multi_export(
|
|
356 |
export_dir = 'multiexport/dirs_with_added_layers',
|
|
357 |
export_format = 'dir',
|
|
358 |
config_args = '--configuration root1.confml '\
|
|
359 |
'--configuration root3.confml '\
|
|
360 |
'--add new/layer1/root.confml '\
|
|
361 |
'--add new/layer2/root.confml ',
|
|
362 |
expected_dirs = [('root1/', 'root1.confml'),
|
|
363 |
('root3/', 'root3.confml')])
|
|
364 |
# Check that the added layers have really been added to the exported
|
|
365 |
# projects
|
|
366 |
def check(path):
|
|
367 |
path = os.path.join(TEMP_DIR, 'multiexport/dirs_with_added_layers', path)
|
|
368 |
self.assert_exists_and_contains_something(path)
|
|
369 |
check('root1/new/layer1/root.confml')
|
|
370 |
check('root1/new/layer2/root.confml')
|
|
371 |
check('root3/new/layer1/root.confml')
|
|
372 |
check('root3/new/layer2/root.confml')
|
|
373 |
|
|
374 |
# Check that the configuration root contains the added layers
|
|
375 |
file_path = os.path.join(TEMP_DIR, 'multiexport/dirs_with_added_layers/root1/root1.confml')
|
|
376 |
data = self.read_data_from_file(file_path)
|
|
377 |
self.assertTrue('href="Layer1/root.confml"' in data)
|
|
378 |
self.assertTrue('href="new/layer1/root.confml"' in data)
|
|
379 |
self.assertTrue('href="new/layer2/root.confml"' in data)
|
|
380 |
|
|
381 |
file_path = os.path.join(TEMP_DIR, 'multiexport/dirs_with_added_layers/root3/root3.confml')
|
|
382 |
data = self.read_data_from_file(file_path)
|
|
383 |
self.assertTrue('href="Layer1/root.confml"' in data)
|
|
384 |
self.assertTrue('href="Layer2/root.confml"' in data)
|
|
385 |
self.assertTrue('href="Layer3/root.confml"' in data)
|
|
386 |
self.assertTrue('href="new/layer1/root.confml"' in data)
|
|
387 |
self.assertTrue('href="new/layer2/root.confml"' in data)
|
|
388 |
|
|
389 |
def test_export_multiple_cpfs_with_wildcard(self):
|
|
390 |
self._run_test_multi_export(
|
|
391 |
export_dir = 'multiexport/cpfs_wildcard',
|
|
392 |
export_format = 'cpf',
|
|
393 |
config_args = '--config-wildcard root*.confml',
|
|
394 |
expected_cpfs = [('root1.cpf', 'root1.confml'),
|
|
395 |
('root2.cpf', 'root2.confml'),
|
|
396 |
('root3.cpf', 'root3.confml'),
|
|
397 |
('root4.cpf', 'root4.confml'),
|
|
398 |
('root5.cpf', 'root5.confml')])
|
|
399 |
|
|
400 |
def test_export_multiple_cpfs_with_regex(self):
|
|
401 |
self._run_test_multi_export(
|
|
402 |
export_dir = 'multiexport/cpfs_regex',
|
|
403 |
export_format = 'cpf',
|
|
404 |
config_args = '--config-regex root[14].confml',
|
|
405 |
expected_cpfs = [('root1.cpf', 'root1.confml'),
|
|
406 |
('root4.cpf', 'root4.confml')])
|
|
407 |
|
5
|
408 |
def test_export_with_include_content_filter_help(self):
|
|
409 |
# test help update
|
|
410 |
cmd = '%s -h' % get_cmd('export')
|
|
411 |
out = self.run_command(cmd)
|
|
412 |
lines = out.split(os.linesep)
|
|
413 |
self.assertTrue(' --include-content-filter=INCLUDE_CONTENT_FILTER' in lines)
|
|
414 |
|
|
415 |
def test_export_with_include_content_filter_project_to_cpf(self):
|
|
416 |
# test cpf export
|
|
417 |
source = os.path.join(TEMP_DIR, "layers")
|
|
418 |
remote = os.path.join(TEMP_DIR, 'layers.cpf')
|
|
419 |
self.remove_if_exists(remote)
|
|
420 |
|
|
421 |
unzip_file(EXPORT_TEST_PROJECT, source, delete_if_exists=True)
|
0
|
422 |
|
5
|
423 |
|
|
424 |
cmd = '%s -p "%s" -c "root4.confml" -r "%s" --include-content-filter="%s"' % (get_cmd('export'), TEST_PROJECT_CPF, remote,".*layer1.*")
|
|
425 |
out = self.run_command(cmd)
|
|
426 |
|
|
427 |
# layer1 content
|
|
428 |
self.assert_zip_entry_exists(remote, "root4.confml")
|
|
429 |
self.assert_zip_entry_exists(remote, "Layer1/content/default_file.txt")
|
|
430 |
self.assert_zip_entry_exists(remote, "Layer1/content/seq/def1_file.txt")
|
|
431 |
|
|
432 |
# filtered content
|
|
433 |
self.assert_zip_entry_exists_not(remote, "Layer2/content/layer2_file.txt")
|
|
434 |
self.assert_zip_entry_exists_not(remote, "Layer3/content/seq/layer3_file.txt")
|
|
435 |
self.assert_zip_entry_exists_not(remote, "Layer4/content/seq/layer4_file.txt")
|
|
436 |
|
|
437 |
def test_export_with_include_content_filter_cpf_to_cpf(self):
|
|
438 |
# test cpf export
|
|
439 |
remote = os.path.join(TEMP_DIR, 'layers2.cpf')
|
|
440 |
self.remove_if_exists(remote)
|
|
441 |
|
|
442 |
|
|
443 |
|
|
444 |
cmd = '%s -p "%s" -c "root4.confml" -r "%s" --include-content-filter="%s"' % (get_cmd('export'), TEST_PROJECT_CPF, remote,".*layer2.*")
|
|
445 |
out = self.run_command(cmd)
|
|
446 |
|
|
447 |
# layer1 content
|
|
448 |
self.assert_zip_entry_exists(remote, "root4.confml")
|
|
449 |
self.assert_zip_entry_exists(remote, "Layer2/content/layer2_file.txt")
|
|
450 |
|
|
451 |
# filtered content
|
|
452 |
self.assert_zip_entry_exists_not(remote, "Layer1/content/default_file.txt")
|
|
453 |
self.assert_zip_entry_exists_not(remote, "Layer3/content/seq/layer3_file.txt")
|
|
454 |
self.assert_zip_entry_exists_not(remote, "Layer4/content/seq/layer4_file.txt")
|
|
455 |
|
|
456 |
|
0
|
457 |
class TestExportInvalidArgs(BaseTestCase):
|
|
458 |
|
|
459 |
def _run_test_invalid_args(self, args, expected_msg):
|
|
460 |
cmd = '%s -p "%s" %s' \
|
|
461 |
% (get_cmd('export'), TEST_PROJECT_CPF, args)
|
|
462 |
# Note: The following run_command() should really expect the
|
|
463 |
# return code 2, but for some reason when running from the
|
|
464 |
# standalone test set, the return value is 0
|
|
465 |
out = self.run_command(cmd, expected_return_code = None)
|
|
466 |
self.assertTrue(expected_msg in out,
|
|
467 |
"Expected message '%s' not in output.\nOutput:\n%s" % (expected_msg, out))
|
|
468 |
|
|
469 |
def test_export_format_without_export_dir(self):
|
|
470 |
self._run_test_invalid_args(
|
|
471 |
'-c root1.confml --export-format cpf',
|
|
472 |
"error: --export-format can only be used in conjunction with --export-dir")
|
|
473 |
|
|
474 |
def test_remote_storage_and_export_dir(self):
|
|
475 |
self._run_test_invalid_args(
|
|
476 |
'-c root1.confml --remote jojo.cpf --export-dir test/',
|
|
477 |
"error: --export-dir and --remote cannot be used at the same time")
|
|
478 |
|
|
479 |
def test_unknown_export_format(self):
|
|
480 |
self._run_test_invalid_args(
|
|
481 |
'-c root1.confml --export-dir test/ --export-format foo',
|
|
482 |
"error: Invalid export format 'foo'")
|
|
483 |
|
|
484 |
def test_export_dir_but_no_configurations(self):
|
|
485 |
self._run_test_invalid_args(
|
|
486 |
'--export-dir test/',
|
|
487 |
"error: Use of --export-dir requires at least one configuration to be specified")
|
|
488 |
|
|
489 |
|
|
490 |
if __name__ == '__main__':
|
3
|
491 |
unittest.main()
|