|
|
|
@ -1392,6 +1392,48 @@ class TestDirectoryProcessor:
|
|
|
|
|
directory_processor.process_template_directories()
|
|
|
|
|
assert os.path.exists(join_paths(CHROOT_PATH, '/etc/copy.gif'))
|
|
|
|
|
|
|
|
|
|
def test_default_raw_and_append_replace(self):
|
|
|
|
|
datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH,
|
|
|
|
|
'templates_43')
|
|
|
|
|
directory_processor = DirectoryProcessor(
|
|
|
|
|
'install',
|
|
|
|
|
datavars_module=datavars,
|
|
|
|
|
package='test-category/test-package'
|
|
|
|
|
)
|
|
|
|
|
directory_processor.process_template_directories()
|
|
|
|
|
assert os.path.exists(join_paths(CHROOT_PATH, '/etc/dir_60/file_0'))
|
|
|
|
|
assert not os.path.exists(join_paths(CHROOT_PATH,
|
|
|
|
|
'/etc/dir_60/._cfg0000_file_0'))
|
|
|
|
|
|
|
|
|
|
def test_default_raw_and_append_replace_contents_not_matching(self):
|
|
|
|
|
template_path = join_paths(CHROOT_PATH,
|
|
|
|
|
"templates_44/install/dir_61/file_0")
|
|
|
|
|
expected_new_text = ('#' + '-' * 79 + '\n' +
|
|
|
|
|
'# Modified by Calculate Utilities 4.0\n' +
|
|
|
|
|
'# Processed template files:\n' +
|
|
|
|
|
f'# { template_path }\n' +
|
|
|
|
|
'#' + '-' * 79 + '\n\nnew content')
|
|
|
|
|
datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH,
|
|
|
|
|
'templates_44')
|
|
|
|
|
directory_processor = DirectoryProcessor(
|
|
|
|
|
'install',
|
|
|
|
|
datavars_module=datavars,
|
|
|
|
|
package='test-category/test-package'
|
|
|
|
|
)
|
|
|
|
|
directory_processor.process_template_directories()
|
|
|
|
|
assert os.path.exists(join_paths(CHROOT_PATH,'/etc/dir_61/file_0'))
|
|
|
|
|
with open(join_paths(CHROOT_PATH,
|
|
|
|
|
'/etc/dir_61/file_0'), 'r') as original_file:
|
|
|
|
|
original_text = original_file.read()
|
|
|
|
|
assert original_text == "old content\n"
|
|
|
|
|
assert os.path.exists(join_paths(CHROOT_PATH,
|
|
|
|
|
'/etc/dir_61/._cfg0000_file_0'))
|
|
|
|
|
with open(join_paths(CHROOT_PATH,
|
|
|
|
|
'/etc/dir_61/._cfg0000_file_0'),
|
|
|
|
|
'r') as new_file:
|
|
|
|
|
new_text = new_file.read()
|
|
|
|
|
assert new_text == expected_new_text
|
|
|
|
|
|
|
|
|
|
def test_view_tree(self):
|
|
|
|
|
list_path = join_paths(CHROOT_PATH, '/etc')
|
|
|
|
|
show_tree(list_path)
|
|
|
|
|