|
|
|
@ -2279,6 +2279,11 @@ class TestTemplateExecutor:
|
|
|
|
|
chroot_path=CHROOT_PATH,
|
|
|
|
|
config_archive_path=CONFIG_ARCHIVE_PATH)
|
|
|
|
|
template_executor._append_replace_file(template_wrapper)
|
|
|
|
|
# template_executor.execute_template(target_path,
|
|
|
|
|
# parameters_object,
|
|
|
|
|
# FILE,
|
|
|
|
|
# '/path/to/template',
|
|
|
|
|
# save_changes=False)
|
|
|
|
|
|
|
|
|
|
assert os.path.exists(target_path)
|
|
|
|
|
assert '/etc/append_after_file_testfiles/file_0'\
|
|
|
|
@ -2991,14 +2996,51 @@ AttributeError: module 'os' has no attribute 'suspicious_attribute'
|
|
|
|
|
'mirror': True})
|
|
|
|
|
|
|
|
|
|
template_wrapper = TemplateWrapper(
|
|
|
|
|
target_path,
|
|
|
|
|
parameters_object, FILE,
|
|
|
|
|
'/path/to/template',
|
|
|
|
|
template_text='',
|
|
|
|
|
chroot_path=CHROOT_PATH,
|
|
|
|
|
config_archive_path=CONFIG_ARCHIVE_PATH)
|
|
|
|
|
target_path,
|
|
|
|
|
parameters_object, FILE,
|
|
|
|
|
'/path/to/template',
|
|
|
|
|
template_text='',
|
|
|
|
|
chroot_path=CHROOT_PATH,
|
|
|
|
|
config_archive_path=CONFIG_ARCHIVE_PATH)
|
|
|
|
|
template_executor._append_join_file(template_wrapper)
|
|
|
|
|
assert os.path.exists(target_path)
|
|
|
|
|
|
|
|
|
|
def test_using_regex_template_with_source(self):
|
|
|
|
|
target_path = join_paths(
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
'/etc/append_join_file_testfiles/file_18')
|
|
|
|
|
source_path = join_paths(
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
'/etc/append_join_file_testfiles/file_17')
|
|
|
|
|
template = '''<reg>root</reg>
|
|
|
|
|
<text>myroot</text>'''
|
|
|
|
|
expected_output = ('#' + '-' * 79 + '\n' +
|
|
|
|
|
'# Modified by Calculate Utilities 4.0\n' +
|
|
|
|
|
'# Processed template files:\n' +
|
|
|
|
|
f'# /path/to/template\n' +
|
|
|
|
|
'#' + '-' * 79 +'\n' +
|
|
|
|
|
"myroot:x:0:0:myroot:/myroot:/bin/bash\n" +
|
|
|
|
|
"bin:x:1:1:bin:/bin:/bin/false\n" +
|
|
|
|
|
"daemon:x:2:2:daemon:/sbin:/bin/false\n" +
|
|
|
|
|
"adm:x:3:4:adm:/var/adm:/bin/false\n")
|
|
|
|
|
|
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
|
|
'append': 'join',
|
|
|
|
|
'source': source_path,
|
|
|
|
|
'format': 'regex'})
|
|
|
|
|
|
|
|
|
|
template_wrapper = TemplateWrapper(
|
|
|
|
|
target_path,
|
|
|
|
|
parameters_object, FILE,
|
|
|
|
|
'/path/to/template',
|
|
|
|
|
template_text=template,
|
|
|
|
|
chroot_path=CHROOT_PATH,
|
|
|
|
|
config_archive_path=CONFIG_ARCHIVE_PATH)
|
|
|
|
|
template_executor._append_join_file(template_wrapper)
|
|
|
|
|
assert os.path.exists(target_path)
|
|
|
|
|
with open(target_path, 'r') as out_file:
|
|
|
|
|
out_text = out_file.read()
|
|
|
|
|
assert out_text == expected_output
|
|
|
|
|
|
|
|
|
|
def test_to_remove_changed_testfiles(self):
|
|
|
|
|
shutil.rmtree(os.path.join(CHROOT_PATH, 'etc'))
|
|
|
|
|