|
|
@ -49,6 +49,12 @@ class TestTemplateExecutor:
|
|
|
|
shutil.copytree(os.path.join(CHROOT_PATH, 'etc.backup'),
|
|
|
|
shutil.copytree(os.path.join(CHROOT_PATH, 'etc.backup'),
|
|
|
|
os.path.join(CHROOT_PATH, 'etc'),
|
|
|
|
os.path.join(CHROOT_PATH, 'etc'),
|
|
|
|
symlinks=True)
|
|
|
|
symlinks=True)
|
|
|
|
|
|
|
|
shutil.copytree(os.path.join(
|
|
|
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'var/lib/calculate/config-archive.backup'),
|
|
|
|
|
|
|
|
os.path.join(CHROOT_PATH,
|
|
|
|
|
|
|
|
'var/lib/calculate/config-archive'),
|
|
|
|
|
|
|
|
symlinks=True)
|
|
|
|
|
|
|
|
|
|
|
|
# Сначала протестируем класс для работы с /var/lib/calculate/config файлом.
|
|
|
|
# Сначала протестируем класс для работы с /var/lib/calculate/config файлом.
|
|
|
|
def test_if_config_file_does_not_exist__a_CalculateConfigFile_object_will_create_one_while_its_initialization(self):
|
|
|
|
def test_if_config_file_does_not_exist__a_CalculateConfigFile_object_will_create_one_while_its_initialization(self):
|
|
|
@ -81,67 +87,79 @@ class TestTemplateExecutor:
|
|
|
|
calculate_config_file = CalculateConfigFile(
|
|
|
|
calculate_config_file = CalculateConfigFile(
|
|
|
|
cl_config_path=CONFIG_PATH,
|
|
|
|
cl_config_path=CONFIG_PATH,
|
|
|
|
cl_chroot_path=CHROOT_PATH)
|
|
|
|
cl_chroot_path=CHROOT_PATH)
|
|
|
|
md5_value = hashlib.md5(open(join_paths(CHROOT_PATH,
|
|
|
|
md5_value = hashlib.md5(open(join_paths(
|
|
|
|
'/etc/file'),
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/config_testfiles/file_0'),
|
|
|
|
'r').read().encode()).hexdigest()
|
|
|
|
'r').read().encode()).hexdigest()
|
|
|
|
calculate_config_file.set_files_md5('/etc/file', md5_value)
|
|
|
|
calculate_config_file.set_files_md5('/etc/config_testfiles/file_0',
|
|
|
|
assert '/etc/file' in calculate_config_file
|
|
|
|
md5_value)
|
|
|
|
assert calculate_config_file._config_dictionary['/etc/file'] ==\
|
|
|
|
assert '/etc/config_testfiles/file_0' in calculate_config_file
|
|
|
|
md5_value
|
|
|
|
assert calculate_config_file._config_dictionary[
|
|
|
|
|
|
|
|
'/etc/config_testfiles/file_0'] == md5_value
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_a_CalculateConfigFile_object_is_initialized__the_object_can_be_used_for_removing_any_file_from_config_file(self):
|
|
|
|
def test_if_a_CalculateConfigFile_object_is_initialized__the_object_can_be_used_for_removing_any_file_from_config_file(self):
|
|
|
|
calculate_config_file = CalculateConfigFile(
|
|
|
|
calculate_config_file = CalculateConfigFile(
|
|
|
|
cl_config_path=CONFIG_PATH,
|
|
|
|
cl_config_path=CONFIG_PATH,
|
|
|
|
cl_chroot_path=CHROOT_PATH)
|
|
|
|
cl_chroot_path=CHROOT_PATH)
|
|
|
|
md5_value = hashlib.md5(open(join_paths(CHROOT_PATH,
|
|
|
|
md5_value = hashlib.md5(open(join_paths(
|
|
|
|
'/etc/file'),
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/config_testfiles/file_1'),
|
|
|
|
'r').read().encode()).hexdigest()
|
|
|
|
'r').read().encode()).hexdigest()
|
|
|
|
calculate_config_file.set_files_md5('/etc/file', md5_value)
|
|
|
|
calculate_config_file.set_files_md5('/etc/config_testfiles/file_1',
|
|
|
|
assert '/etc/file' in calculate_config_file
|
|
|
|
md5_value)
|
|
|
|
|
|
|
|
assert '/etc/config_testfiles/file_1' in calculate_config_file
|
|
|
|
|
|
|
|
|
|
|
|
calculate_config_file.remove_file('/etc/file')
|
|
|
|
calculate_config_file.remove_file('/etc/config_testfiles/file_1')
|
|
|
|
assert '/etc/file' not in calculate_config_file
|
|
|
|
assert '/etc/config_testfiles/file_1' not in calculate_config_file
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_a_CalculateConfigFile_object_contains_file_with_its_hash_and_the_hash_compared_with_equal_hash__the_compare_md5_method_returns_True(self):
|
|
|
|
def test_if_a_CalculateConfigFile_object_contains_file_with_its_hash_and_the_hash_compared_with_equal_hash__the_compare_md5_method_returns_True(self):
|
|
|
|
calculate_config_file = CalculateConfigFile(
|
|
|
|
calculate_config_file = CalculateConfigFile(
|
|
|
|
cl_config_path=CONFIG_PATH,
|
|
|
|
cl_config_path=CONFIG_PATH,
|
|
|
|
cl_chroot_path=CHROOT_PATH)
|
|
|
|
cl_chroot_path=CHROOT_PATH)
|
|
|
|
md5_value = hashlib.md5(open(join_paths(CHROOT_PATH,
|
|
|
|
md5_value = hashlib.md5(open(join_paths(
|
|
|
|
'/etc/file'),
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/config_testfiles/file_2'),
|
|
|
|
'r').read().encode()).hexdigest()
|
|
|
|
'r').read().encode()).hexdigest()
|
|
|
|
calculate_config_file.set_files_md5('/etc/file', md5_value)
|
|
|
|
calculate_config_file.set_files_md5('/etc/config_testfiles/file_2',
|
|
|
|
|
|
|
|
md5_value)
|
|
|
|
|
|
|
|
|
|
|
|
assert calculate_config_file.compare_md5('/etc/file', md5_value)
|
|
|
|
assert calculate_config_file.compare_md5(
|
|
|
|
|
|
|
|
'/etc/config_testfiles/file_2', md5_value)
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_a_CalculateConfigFile_object_contains_file_with_its_hash_and_the_hash_compared_with_not_equal_hash__the_compare_md5_method_returns_False(self):
|
|
|
|
def test_if_a_CalculateConfigFile_object_contains_file_with_its_hash_and_the_hash_compared_with_not_equal_hash__the_compare_md5_method_returns_False(self):
|
|
|
|
calculate_config_file = CalculateConfigFile(
|
|
|
|
calculate_config_file = CalculateConfigFile(
|
|
|
|
cl_config_path=CONFIG_PATH,
|
|
|
|
cl_config_path=CONFIG_PATH,
|
|
|
|
cl_chroot_path=CHROOT_PATH)
|
|
|
|
cl_chroot_path=CHROOT_PATH)
|
|
|
|
md5_value_1 = hashlib.md5(open(join_paths(CHROOT_PATH,
|
|
|
|
md5_value_1 = hashlib.md5(open(join_paths(
|
|
|
|
'/etc/file'),
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/config_testfiles/file_3'),
|
|
|
|
'r').read().encode()).hexdigest()
|
|
|
|
'r').read().encode()).hexdigest()
|
|
|
|
calculate_config_file.set_files_md5('/etc/file', md5_value_1)
|
|
|
|
calculate_config_file.set_files_md5('/etc/config_testfiles/file_3',
|
|
|
|
|
|
|
|
md5_value_1)
|
|
|
|
|
|
|
|
|
|
|
|
if os.path.exists(join_paths(CHROOT_PATH,
|
|
|
|
if os.path.exists(join_paths(CHROOT_PATH,
|
|
|
|
'/etc/config_testfiles/file.conf')):
|
|
|
|
'/etc/config_testfiles/file_4')):
|
|
|
|
print('File exists')
|
|
|
|
print('File exists')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print('File does not exist')
|
|
|
|
print('File does not exist')
|
|
|
|
md5_value_2 = hashlib.md5(open(join_paths(
|
|
|
|
md5_value_2 = hashlib.md5(open(join_paths(
|
|
|
|
CHROOT_PATH,
|
|
|
|
CHROOT_PATH,
|
|
|
|
'/etc/config_testfiles/file.conf'),
|
|
|
|
'/etc/config_testfiles/file_4'),
|
|
|
|
'r').read().encode()).hexdigest()
|
|
|
|
'r').read().encode()).hexdigest()
|
|
|
|
assert not calculate_config_file.compare_md5('/etc/file', md5_value_2)
|
|
|
|
assert not calculate_config_file.compare_md5(
|
|
|
|
|
|
|
|
'/etc/config_testfiles/file_3', md5_value_2)
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_a_CalculateConfigFile_object_is_used_for_comparing_a_hash_with_a_hash_of_a_file_that_is_not_in_the_config_file__the_compare_md5_method_returns_False(self):
|
|
|
|
def test_if_a_CalculateConfigFile_object_is_used_for_comparing_a_hash_with_a_hash_of_a_file_that_is_not_in_the_config_file__the_compare_md5_method_returns_False(self):
|
|
|
|
calculate_config_file = CalculateConfigFile(
|
|
|
|
calculate_config_file = CalculateConfigFile(
|
|
|
|
cl_config_path=CONFIG_PATH,
|
|
|
|
cl_config_path=CONFIG_PATH,
|
|
|
|
cl_chroot_path=CHROOT_PATH)
|
|
|
|
cl_chroot_path=CHROOT_PATH)
|
|
|
|
md5_value = hashlib.md5(open(join_paths(CHROOT_PATH,
|
|
|
|
md5_value = hashlib.md5(open(join_paths(
|
|
|
|
'/etc/file'),
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/config_testfiles/file_5'),
|
|
|
|
'r').read().encode()).hexdigest()
|
|
|
|
'r').read().encode()).hexdigest()
|
|
|
|
|
|
|
|
|
|
|
|
assert not calculate_config_file.compare_md5('/etc/file', md5_value)
|
|
|
|
assert not calculate_config_file.compare_md5(
|
|
|
|
|
|
|
|
'/etc/config_testfiles/file_5', md5_value)
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_a_CalculateConfigFile_object_was_used_to_make_changes_in_the_config_file__the_save_changes_method_will_save_the_changes(self):
|
|
|
|
def test_if_a_CalculateConfigFile_object_was_used_to_make_changes_in_the_config_file__the_save_changes_method_will_save_the_changes(self):
|
|
|
|
temporary_chroot = join_paths(
|
|
|
|
temporary_chroot = join_paths(
|
|
|
@ -396,7 +414,7 @@ class TestTemplateExecutor:
|
|
|
|
assert dir_owner == template_executor._get_file_owner(target_directory)
|
|
|
|
assert dir_owner == template_executor._get_file_owner(target_directory)
|
|
|
|
assert dir_mode == template_executor._get_file_mode(target_directory)
|
|
|
|
assert dir_mode == template_executor._get_file_mode(target_directory)
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_the_create_directory_method_input_is_a_template_with_a_target_path_to_an_existing_directory_and_chown_and_chmod_parameters_is_set__the_method_does_nothing(self):
|
|
|
|
def test_if_the_create_directory_method_input_is_a_template_with_a_target_path_to_an_existing_directory_and_chown_and_chmod_parameters_is_set__the_method_chmod_and_chown_target_file(self):
|
|
|
|
target_directory = join_paths(CHROOT_PATH,
|
|
|
|
target_directory = join_paths(CHROOT_PATH,
|
|
|
|
'/etc/create_dir_testfiles/dir_0')
|
|
|
|
'/etc/create_dir_testfiles/dir_0')
|
|
|
|
chown_value = {'uid': os.getuid(), 'gid': os.getgid()}
|
|
|
|
chown_value = {'uid': os.getuid(), 'gid': os.getgid()}
|
|
|
@ -446,7 +464,7 @@ class TestTemplateExecutor:
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_the_create_directory_method_input_is_a_template_with_a_target_path_to_an_unexisting_directory_from_an_existing_directory_and_chown_and_chmod_parameters_is_set__the_method_one_new_directory_with_a_mode_and_an_owner_from_the_parameters(self):
|
|
|
|
def test_if_the_create_directory_method_input_is_a_template_with_a_target_path_to_an_unexisting_directory_from_an_existing_directory_and_chown_and_chmod_parameters_is_set__the_method_one_new_directory_with_a_mode_and_an_owner_from_the_parameters(self):
|
|
|
|
target_directory = join_paths(CHROOT_PATH,
|
|
|
|
target_directory = join_paths(CHROOT_PATH,
|
|
|
|
'/etc/create_dir_testfiles/dir_1/subdir')
|
|
|
|
'/etc/create_dir_testfiles/dir_2/subdir')
|
|
|
|
chown_value = {'uid': os.getuid(), 'gid': os.getgid()}
|
|
|
|
chown_value = {'uid': os.getuid(), 'gid': os.getgid()}
|
|
|
|
chmod_value = int(0o777)
|
|
|
|
chmod_value = int(0o777)
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
@ -469,9 +487,9 @@ class TestTemplateExecutor:
|
|
|
|
def test_if_the_create_directory_method_input_is_a_template_with_a_target_path_to_an_unexisting_directory_from_an_unexisting_directory_and_chown_and_chmod_parameters_is_not_set__the_method_creates_new_directory_and_all_its_parents_with_a_mode_and_an_owner_of_its_existing_parent(self):
|
|
|
|
def test_if_the_create_directory_method_input_is_a_template_with_a_target_path_to_an_unexisting_directory_from_an_unexisting_directory_and_chown_and_chmod_parameters_is_not_set__the_method_creates_new_directory_and_all_its_parents_with_a_mode_and_an_owner_of_its_existing_parent(self):
|
|
|
|
target_directory = join_paths(
|
|
|
|
target_directory = join_paths(
|
|
|
|
CHROOT_PATH,
|
|
|
|
CHROOT_PATH,
|
|
|
|
'/etc/create_dir_testfiles/dir_2/subdir/subsubdir')
|
|
|
|
'/etc/create_dir_testfiles/dir_3/subdir/subsubdir')
|
|
|
|
parent_directory = join_paths(CHROOT_PATH,
|
|
|
|
parent_directory = join_paths(CHROOT_PATH,
|
|
|
|
'/etc/create_dir_testfiles/dir_2')
|
|
|
|
'/etc/create_dir_testfiles/dir_3')
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
|
'append': 'join'})
|
|
|
|
'append': 'join'})
|
|
|
|
chown_value = {'uid': os.getuid(), 'gid': os.getgid()}
|
|
|
|
chown_value = {'uid': os.getuid(), 'gid': os.getgid()}
|
|
|
@ -500,7 +518,7 @@ class TestTemplateExecutor:
|
|
|
|
def test_if_the_create_directory_method_s_input_is_a_template_with_a_target_path_to_an_unexisting_directory_from_an_unexisting_directory_and_chown_and_chmod_parameters_is_set__the_method_creates_new_directory_and_all_its_parents_with_a_mode_and_an_owner_from_the_parameters(self):
|
|
|
|
def test_if_the_create_directory_method_s_input_is_a_template_with_a_target_path_to_an_unexisting_directory_from_an_unexisting_directory_and_chown_and_chmod_parameters_is_set__the_method_creates_new_directory_and_all_its_parents_with_a_mode_and_an_owner_from_the_parameters(self):
|
|
|
|
target_directory = join_paths(
|
|
|
|
target_directory = join_paths(
|
|
|
|
CHROOT_PATH,
|
|
|
|
CHROOT_PATH,
|
|
|
|
'/etc/create_dir_testfiles/dir_2/subdir/subsubdir')
|
|
|
|
'/etc/create_dir_testfiles/dir_4/subdir/subsubdir')
|
|
|
|
chown_value = {'uid': os.getuid(), 'gid': os.getgid()}
|
|
|
|
chown_value = {'uid': os.getuid(), 'gid': os.getgid()}
|
|
|
|
chmod_value = int(0o777)
|
|
|
|
chmod_value = int(0o777)
|
|
|
|
|
|
|
|
|
|
|
@ -535,19 +553,10 @@ class TestTemplateExecutor:
|
|
|
|
assert os.path.exists(target_path)
|
|
|
|
assert os.path.exists(target_path)
|
|
|
|
assert os.path.islink(target_path)
|
|
|
|
assert os.path.islink(target_path)
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_the_link_directory_method_s_input_is_a_path_to_an_existing_source_file_and_a_target_path__the_method_creates_a_link_to_a_source_file(self):
|
|
|
|
|
|
|
|
target_path = join_paths(CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/link_dir_testfiles/link_dir_1')
|
|
|
|
|
|
|
|
source_path = join_paths(CHROOT_PATH, '/etc/link_dir_testfiles/file_1')
|
|
|
|
|
|
|
|
template_executor._link_directory(source_path, target_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert os.path.exists(target_path)
|
|
|
|
|
|
|
|
assert os.path.islink(target_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_the_link_directory_method_s_input_is_a_path_to_an_existing_source_directory_and_a_target_path_to_an_existing_link__the_method_raises_the_TemplateExecutorError_exception(self):
|
|
|
|
def test_if_the_link_directory_method_s_input_is_a_path_to_an_existing_source_directory_and_a_target_path_to_an_existing_link__the_method_raises_the_TemplateExecutorError_exception(self):
|
|
|
|
target_path = join_paths(CHROOT_PATH,
|
|
|
|
target_path = join_paths(CHROOT_PATH,
|
|
|
|
'/etc/link_dir_testfiles/link_dir_2')
|
|
|
|
'/etc/link_dir_testfiles/link_dir_1')
|
|
|
|
source_path = join_paths(CHROOT_PATH, '/etc/link_dir_testfiles/dir_2')
|
|
|
|
source_path = join_paths(CHROOT_PATH, '/etc/link_dir_testfiles/dir_1')
|
|
|
|
|
|
|
|
|
|
|
|
with pytest.raises(TemplateExecutorError):
|
|
|
|
with pytest.raises(TemplateExecutorError):
|
|
|
|
template_executor._link_directory(source_path, target_path)
|
|
|
|
template_executor._link_directory(source_path, target_path)
|
|
|
@ -634,7 +643,7 @@ class TestTemplateExecutor:
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_the_clear_directory_method_s_input_is_a_path_to_a_file__the_method_raises_TemplateExecutorError_exception(self):
|
|
|
|
def test_if_the_clear_directory_method_s_input_is_a_path_to_a_file__the_method_raises_TemplateExecutorError_exception(self):
|
|
|
|
target_path = join_paths(CHROOT_PATH,
|
|
|
|
target_path = join_paths(CHROOT_PATH,
|
|
|
|
'/etc/clear_dir_testfiles/file')
|
|
|
|
'/etc/clear_dir_testfiles/file_0')
|
|
|
|
|
|
|
|
|
|
|
|
with pytest.raises(TemplateExecutorError):
|
|
|
|
with pytest.raises(TemplateExecutorError):
|
|
|
|
template_executor._clear_directory(target_path)
|
|
|
|
template_executor._clear_directory(target_path)
|
|
|
@ -649,7 +658,7 @@ class TestTemplateExecutor:
|
|
|
|
assert os.path.exists(target_path)
|
|
|
|
assert os.path.exists(target_path)
|
|
|
|
assert os.path.islink(target_path)
|
|
|
|
assert os.path.islink(target_path)
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_the_link_file_method_s_input_is_a_path_to_an_existing_source_file_and_a_target_path_to_an_existing_file__the_method_creates_a_link_to_a_source_file(self):
|
|
|
|
def test_if_the_link_file_method_s_input_is_a_path_to_an_existing_source_file_and_a_target_path_to_an_existing_file__the_method_throws_TemplateExecutorError_exception(self):
|
|
|
|
target_path = join_paths(CHROOT_PATH,
|
|
|
|
target_path = join_paths(CHROOT_PATH,
|
|
|
|
'/etc/link_file_testfiles/link_file_1')
|
|
|
|
'/etc/link_file_testfiles/link_file_1')
|
|
|
|
source_path = join_paths(CHROOT_PATH,
|
|
|
|
source_path = join_paths(CHROOT_PATH,
|
|
|
@ -658,14 +667,14 @@ class TestTemplateExecutor:
|
|
|
|
with pytest.raises(TemplateExecutorError):
|
|
|
|
with pytest.raises(TemplateExecutorError):
|
|
|
|
template_executor._link_file(source_path, target_path)
|
|
|
|
template_executor._link_file(source_path, target_path)
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_the_remove_file_method_s_input_is_a_path_to_an_existing_file__the_method_raises_TemplateExecutorError_exception(self):
|
|
|
|
def test_if_the_remove_file_method_s_input_is_a_path_to_an_existing_file__the_method_removes_a_file(self):
|
|
|
|
target_path = join_paths(CHROOT_PATH,
|
|
|
|
target_path = join_paths(CHROOT_PATH,
|
|
|
|
'/etc/remove_file_testfiles/file_0')
|
|
|
|
'/etc/remove_file_testfiles/file_0')
|
|
|
|
|
|
|
|
|
|
|
|
template_executor._remove_file(target_path)
|
|
|
|
template_executor._remove_file(target_path)
|
|
|
|
assert not os.path.exists(target_path)
|
|
|
|
assert not os.path.exists(target_path)
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_the_remove_file_method_s_input_is_a_path_to_an_existing_link_to_an_existing_file__the_method_raises_TemplateExecutorError_exception(self):
|
|
|
|
def test_if_the_remove_file_method_s_input_is_a_path_to_an_existing_link_to_an_existing_file__the_method_removes_a_file(self):
|
|
|
|
target_path = join_paths(CHROOT_PATH,
|
|
|
|
target_path = join_paths(CHROOT_PATH,
|
|
|
|
'/etc/remove_file_testfiles/link_file_1')
|
|
|
|
'/etc/remove_file_testfiles/link_file_1')
|
|
|
|
source_path = join_paths(CHROOT_PATH,
|
|
|
|
source_path = join_paths(CHROOT_PATH,
|
|
|
@ -974,23 +983,6 @@ class TestTemplateExecutor:
|
|
|
|
assert template_executor._get_file_owner(target_path) == chown_value
|
|
|
|
assert template_executor._get_file_owner(target_path) == chown_value
|
|
|
|
assert template_executor._get_file_mode(target_path) == chmod_value
|
|
|
|
assert template_executor._get_file_mode(target_path) == chmod_value
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_to_contents(self):
|
|
|
|
|
|
|
|
if False:
|
|
|
|
|
|
|
|
target_path = join_paths(
|
|
|
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/append_replace_dir_testfiles/dir_5')
|
|
|
|
|
|
|
|
parameters_object = ParametersContainer(
|
|
|
|
|
|
|
|
{'package': test_package_name,
|
|
|
|
|
|
|
|
'append': 'replace'})
|
|
|
|
|
|
|
|
template_wrapper = TemplateWrapper(
|
|
|
|
|
|
|
|
target_path,
|
|
|
|
|
|
|
|
parameters_object, DIR,
|
|
|
|
|
|
|
|
chroot_path=CHROOT_PATH,
|
|
|
|
|
|
|
|
config_archive_path=CONFIG_ARCHIVE_PATH)
|
|
|
|
|
|
|
|
template_wrapper.target_package.add_sym('/etc/append_replace_dir_testfiles/dir_5/link')
|
|
|
|
|
|
|
|
template_wrapper.save_changes()
|
|
|
|
|
|
|
|
assert True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_append_replace_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_empty_directory_that_belongs_to_the_template_package__the_method_does_nothing(self):
|
|
|
|
def test_if_append_replace_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_empty_directory_that_belongs_to_the_template_package__the_method_does_nothing(self):
|
|
|
|
target_path = join_paths(
|
|
|
|
target_path = join_paths(
|
|
|
|
CHROOT_PATH,
|
|
|
|
CHROOT_PATH,
|
|
|
@ -1073,7 +1065,7 @@ class TestTemplateExecutor:
|
|
|
|
assert '/etc/append_replace_dir_testfiles/dir_5/link'\
|
|
|
|
assert '/etc/append_replace_dir_testfiles/dir_5/link'\
|
|
|
|
not in template_wrapper.target_package
|
|
|
|
not in template_wrapper.target_package
|
|
|
|
|
|
|
|
|
|
|
|
def test_append_link_directory_method_s_input_is_a_template_with_a_target_path_and_a_source_path_to_the_existing_directory__the_method_creates_a_link_to_the_source_directory(self):
|
|
|
|
def test_if_append_link_directory_method_s_input_is_a_template_with_a_target_path_and_a_source_path_to_the_existing_directory__the_method_creates_a_link_to_the_source_directory_and_adds_this_link_to_the_package_CONTENTS_file(self):
|
|
|
|
target_path = join_paths(
|
|
|
|
target_path = join_paths(
|
|
|
|
CHROOT_PATH,
|
|
|
|
CHROOT_PATH,
|
|
|
|
'/etc/append_link_dir_testfiles/link_dir_0')
|
|
|
|
'/etc/append_link_dir_testfiles/link_dir_0')
|
|
|
@ -1094,7 +1086,10 @@ class TestTemplateExecutor:
|
|
|
|
assert os.path.islink(target_path)
|
|
|
|
assert os.path.islink(target_path)
|
|
|
|
assert os.readlink(target_path) == source_path
|
|
|
|
assert os.readlink(target_path) == source_path
|
|
|
|
|
|
|
|
|
|
|
|
def test_append_link_directory_method_s_input_is_a_template_with_a_target_path_and_a_source_path_to_the_existing_directory_and_the_chown_and_chmod_parameters_are_set__the_method_creates_a_link_to_the_source_directory(self):
|
|
|
|
assert '/etc/append_link_dir_testfiles/link_dir_0'\
|
|
|
|
|
|
|
|
in template_wrapper.target_package
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_append_link_directory_method_s_input_is_a_template_with_a_target_path_and_a_source_path_to_the_existing_directory_and_the_chown_and_chmod_parameters_are_set__the_method_creates_a_link_to_the_source_directory_and_adds_this_link_to_the_package_CONTENTS_file(self):
|
|
|
|
target_path = join_paths(
|
|
|
|
target_path = join_paths(
|
|
|
|
CHROOT_PATH,
|
|
|
|
CHROOT_PATH,
|
|
|
|
'/etc/append_link_dir_testfiles/link_dir_1')
|
|
|
|
'/etc/append_link_dir_testfiles/link_dir_1')
|
|
|
@ -1118,9 +1113,277 @@ class TestTemplateExecutor:
|
|
|
|
template_executor._append_link_directory(template_wrapper)
|
|
|
|
template_executor._append_link_directory(template_wrapper)
|
|
|
|
assert os.path.exists(target_path)
|
|
|
|
assert os.path.exists(target_path)
|
|
|
|
assert os.path.islink(target_path)
|
|
|
|
assert os.path.islink(target_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert '/etc/append_link_dir_testfiles/link_dir_1'\
|
|
|
|
|
|
|
|
in template_wrapper.target_package
|
|
|
|
|
|
|
|
|
|
|
|
assert os.readlink(target_path) == source_path
|
|
|
|
assert os.readlink(target_path) == source_path
|
|
|
|
assert template_executor._get_file_owner(target_path) == chown_value
|
|
|
|
assert template_executor._get_file_owner(target_path) == chown_value
|
|
|
|
assert template_executor._get_file_mode(target_path) == chmod_value
|
|
|
|
assert template_executor._get_file_mode(target_path) == chmod_value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_not_exist__the_method_creates_new_empty_file_joins_a_template_with_them_adds_file_to_the_package_CONTENTS_file_and_create_an_archive_version_of_a_file(self):
|
|
|
|
|
|
|
|
target_path = join_paths(
|
|
|
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_0')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
|
|
|
|
|
'append': 'join',
|
|
|
|
|
|
|
|
'format': 'bind'})
|
|
|
|
|
|
|
|
template_text = 'section-name { parameter-2 no; }'
|
|
|
|
|
|
|
|
output_text = 'section-name {\n parameter-2 no;\n};\n'
|
|
|
|
|
|
|
|
template_wrapper = TemplateWrapper(
|
|
|
|
|
|
|
|
target_path,
|
|
|
|
|
|
|
|
parameters_object, FILE,
|
|
|
|
|
|
|
|
template_text=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)
|
|
|
|
|
|
|
|
assert os.path.exists(join_paths(
|
|
|
|
|
|
|
|
CONFIG_ARCHIVE_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_0'))
|
|
|
|
|
|
|
|
assert '/etc/append_join_file_testfiles/file_0'\
|
|
|
|
|
|
|
|
in template_wrapper.target_package
|
|
|
|
|
|
|
|
with open(template_wrapper.output_path, 'r') as output_file:
|
|
|
|
|
|
|
|
assert output_file.read() == output_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_exist__the_method_creates_new_empty_cfg_file_joins_a_template_with_them_and_adds_it_to_config_file(self):
|
|
|
|
|
|
|
|
target_path = join_paths(
|
|
|
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_1')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
|
|
|
|
|
'append': 'join',
|
|
|
|
|
|
|
|
'format': 'bind'})
|
|
|
|
|
|
|
|
template_text = 'section-name { parameter-2 no; }'
|
|
|
|
|
|
|
|
output_text = 'section-name {\n parameter-2 no;\n};\n'
|
|
|
|
|
|
|
|
template_wrapper = TemplateWrapper(
|
|
|
|
|
|
|
|
target_path,
|
|
|
|
|
|
|
|
parameters_object, FILE,
|
|
|
|
|
|
|
|
template_text=template_text,
|
|
|
|
|
|
|
|
chroot_path=CHROOT_PATH,
|
|
|
|
|
|
|
|
config_archive_path=CONFIG_ARCHIVE_PATH)
|
|
|
|
|
|
|
|
template_executor._append_join_file(template_wrapper)
|
|
|
|
|
|
|
|
assert os.path.exists(os.path.join(os.path.dirname(target_path),
|
|
|
|
|
|
|
|
'._cfg0001_file_1'))
|
|
|
|
|
|
|
|
assert not os.path.exists(join_paths(
|
|
|
|
|
|
|
|
CONFIG_ARCHIVE_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_1'))
|
|
|
|
|
|
|
|
assert '/etc/append_join_file_testfiles/file_1'\
|
|
|
|
|
|
|
|
in template_executor.calculate_config_file
|
|
|
|
|
|
|
|
with open(template_wrapper.output_path, 'r') as output_file:
|
|
|
|
|
|
|
|
assert output_file.read() == output_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_exist_and_autoupdate_parameters_is_set__the_method_creates_new_empty_file_joins_a_template_with_them_and_adds_it_to_config_file(self):
|
|
|
|
|
|
|
|
target_path = join_paths(
|
|
|
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_2')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
|
|
|
|
|
'append': 'join',
|
|
|
|
|
|
|
|
'format': 'bind',
|
|
|
|
|
|
|
|
'autoupdate': True})
|
|
|
|
|
|
|
|
template_text = 'section-name { parameter-2 no; }'
|
|
|
|
|
|
|
|
output_text = 'section-name {\n parameter-2 no;\n};\n'
|
|
|
|
|
|
|
|
template_wrapper = TemplateWrapper(
|
|
|
|
|
|
|
|
target_path,
|
|
|
|
|
|
|
|
parameters_object, FILE,
|
|
|
|
|
|
|
|
template_text=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)
|
|
|
|
|
|
|
|
assert os.path.exists(join_paths(
|
|
|
|
|
|
|
|
CONFIG_ARCHIVE_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_2'))
|
|
|
|
|
|
|
|
assert '/etc/append_join_file_testfiles/file_2'\
|
|
|
|
|
|
|
|
in template_wrapper.target_package
|
|
|
|
|
|
|
|
with open(template_wrapper.output_path, 'r') as output_file:
|
|
|
|
|
|
|
|
assert output_file.read() == output_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_not_exist_and_chown_and_chmod_parameters_are_set__the_method_creates_new_empty_file__joins_a_template_with_them__adds_file_to_the_package_CONTENTS_file__create_an_archive_version_of_a_file_and_chown_and_chmod_it(self):
|
|
|
|
|
|
|
|
target_path = join_paths(
|
|
|
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_3')
|
|
|
|
|
|
|
|
chown_value = {'uid': os.getuid(), 'gid': os.getgid()}
|
|
|
|
|
|
|
|
chmod_value = int(0o777)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
archive_path = join_paths(CONFIG_ARCHIVE_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_3')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
|
|
|
|
|
'append': 'join',
|
|
|
|
|
|
|
|
'format': 'bind',
|
|
|
|
|
|
|
|
'chown': chown_value,
|
|
|
|
|
|
|
|
'chmod': chmod_value})
|
|
|
|
|
|
|
|
template_text = 'section-name { parameter-2 no; }'
|
|
|
|
|
|
|
|
output_text = 'section-name {\n parameter-2 no;\n};\n'
|
|
|
|
|
|
|
|
template_wrapper = TemplateWrapper(
|
|
|
|
|
|
|
|
target_path,
|
|
|
|
|
|
|
|
parameters_object, FILE,
|
|
|
|
|
|
|
|
template_text=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)
|
|
|
|
|
|
|
|
assert template_executor._get_file_owner(target_path) == chown_value
|
|
|
|
|
|
|
|
assert template_executor._get_file_mode(target_path) == chmod_value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert os.path.exists(archive_path)
|
|
|
|
|
|
|
|
assert template_executor._get_file_owner(archive_path) == chown_value
|
|
|
|
|
|
|
|
assert template_executor._get_file_mode(archive_path) == chmod_value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert '/etc/append_join_file_testfiles/file_3'\
|
|
|
|
|
|
|
|
in template_wrapper.target_package
|
|
|
|
|
|
|
|
with open(template_wrapper.output_path, 'r') as output_file:
|
|
|
|
|
|
|
|
assert output_file.read() == output_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_exist_and_chown_and_chmod_parameters_are_set__the_method_creates_new_empty_cfg_file__joins_a_template_with_them__adds_it_to_config_file_and_chown_and_chmod_it(self):
|
|
|
|
|
|
|
|
target_path = join_paths(
|
|
|
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_4')
|
|
|
|
|
|
|
|
chown_value = {'uid': os.getuid(), 'gid': os.getgid()}
|
|
|
|
|
|
|
|
chmod_value = int(0o777)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
|
|
|
|
|
'append': 'join', 'format': 'bind',
|
|
|
|
|
|
|
|
'chown': chown_value,
|
|
|
|
|
|
|
|
'chmod': chmod_value})
|
|
|
|
|
|
|
|
output_path = os.path.join(os.path.dirname(target_path),
|
|
|
|
|
|
|
|
'._cfg0001_file_4')
|
|
|
|
|
|
|
|
template_text = 'section-name { parameter-2 no; }'
|
|
|
|
|
|
|
|
output_text = 'section-name {\n parameter-2 no;\n};\n'
|
|
|
|
|
|
|
|
template_wrapper = TemplateWrapper(
|
|
|
|
|
|
|
|
target_path,
|
|
|
|
|
|
|
|
parameters_object, FILE,
|
|
|
|
|
|
|
|
template_text=template_text,
|
|
|
|
|
|
|
|
chroot_path=CHROOT_PATH,
|
|
|
|
|
|
|
|
config_archive_path=CONFIG_ARCHIVE_PATH)
|
|
|
|
|
|
|
|
template_executor._append_join_file(template_wrapper)
|
|
|
|
|
|
|
|
assert os.path.exists(output_path)
|
|
|
|
|
|
|
|
assert template_executor._get_file_owner(output_path) == chown_value
|
|
|
|
|
|
|
|
assert template_executor._get_file_mode(output_path) == chmod_value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert not os.path.exists(join_paths(
|
|
|
|
|
|
|
|
CONFIG_ARCHIVE_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_4'))
|
|
|
|
|
|
|
|
assert '/etc/append_join_file_testfiles/file_4'\
|
|
|
|
|
|
|
|
in template_executor.calculate_config_file
|
|
|
|
|
|
|
|
with open(template_wrapper.output_path, 'r') as output_file:
|
|
|
|
|
|
|
|
assert output_file.read() == output_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_to_contents(self):
|
|
|
|
|
|
|
|
if False:
|
|
|
|
|
|
|
|
target_path = join_paths(
|
|
|
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_5')
|
|
|
|
|
|
|
|
parameters_object = ParametersContainer(
|
|
|
|
|
|
|
|
{'package': test_package_name,
|
|
|
|
|
|
|
|
'append': 'join'})
|
|
|
|
|
|
|
|
template_wrapper = TemplateWrapper(
|
|
|
|
|
|
|
|
target_path,
|
|
|
|
|
|
|
|
parameters_object, FILE,
|
|
|
|
|
|
|
|
chroot_path=CHROOT_PATH,
|
|
|
|
|
|
|
|
config_archive_path=CONFIG_ARCHIVE_PATH)
|
|
|
|
|
|
|
|
template_wrapper.add_to_contents()
|
|
|
|
|
|
|
|
template_wrapper.save_changes()
|
|
|
|
|
|
|
|
assert True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_and_its_hash_sum_matches_the_hash_from_a_CONTENTS_file__the_method_joins_an_input_file_with_a_template__changes_its_hash_in_the_CONTENTS__updates_config_archive(self):
|
|
|
|
|
|
|
|
target_path = join_paths(
|
|
|
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_5')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
|
|
|
|
|
'append': 'join',
|
|
|
|
|
|
|
|
'format': 'bind'})
|
|
|
|
|
|
|
|
template_text = 'section-name { parameter-2 no; }'
|
|
|
|
|
|
|
|
output_text =\
|
|
|
|
|
|
|
|
'section-name {\n parameter-1 yes;\n parameter-2 no;\n};\n'
|
|
|
|
|
|
|
|
template_wrapper = TemplateWrapper(
|
|
|
|
|
|
|
|
target_path,
|
|
|
|
|
|
|
|
parameters_object, FILE,
|
|
|
|
|
|
|
|
template_text=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)
|
|
|
|
|
|
|
|
assert os.path.exists(join_paths(
|
|
|
|
|
|
|
|
CONFIG_ARCHIVE_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_5'))
|
|
|
|
|
|
|
|
assert '/etc/append_join_file_testfiles/file_5'\
|
|
|
|
|
|
|
|
in template_wrapper.target_package
|
|
|
|
|
|
|
|
with open(template_wrapper.output_path, 'r') as output_file:
|
|
|
|
|
|
|
|
assert output_file.read() == output_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_its_hash_sum_matches_the_hash_from_a_CONTENTS_file_and_a_chown_and_chmod_parameters_are_set__the_method_joins_an_input_file_with_a_template__changes_its_hash_in_the_CONTENTS__updates_config_archive_and_chown_and_chmod_it(self):
|
|
|
|
|
|
|
|
target_path = join_paths(
|
|
|
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_6')
|
|
|
|
|
|
|
|
chown_value = {'uid': os.getuid(), 'gid': os.getgid()}
|
|
|
|
|
|
|
|
chmod_value = int(0o777)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
archive_path = join_paths(CONFIG_ARCHIVE_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_6')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
|
|
|
|
|
'append': 'join',
|
|
|
|
|
|
|
|
'format': 'bind',
|
|
|
|
|
|
|
|
'chown': chown_value,
|
|
|
|
|
|
|
|
'chmod': chmod_value})
|
|
|
|
|
|
|
|
template_text = 'section-name { parameter-2 no; }'
|
|
|
|
|
|
|
|
output_text =\
|
|
|
|
|
|
|
|
'section-name {\n parameter-1 yes;\n parameter-2 no;\n};\n'
|
|
|
|
|
|
|
|
template_wrapper = TemplateWrapper(
|
|
|
|
|
|
|
|
target_path,
|
|
|
|
|
|
|
|
parameters_object, FILE,
|
|
|
|
|
|
|
|
template_text=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)
|
|
|
|
|
|
|
|
assert template_executor._get_file_owner(target_path) == chown_value
|
|
|
|
|
|
|
|
assert template_executor._get_file_mode(target_path) == chmod_value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert os.path.exists(archive_path)
|
|
|
|
|
|
|
|
assert template_executor._get_file_owner(archive_path) == chown_value
|
|
|
|
|
|
|
|
assert template_executor._get_file_mode(archive_path) == chmod_value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert '/etc/append_join_file_testfiles/file_6'\
|
|
|
|
|
|
|
|
in template_wrapper.target_package
|
|
|
|
|
|
|
|
with open(template_wrapper.output_path, 'r') as output_file:
|
|
|
|
|
|
|
|
assert output_file.read() == output_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file__the_method_creates_a_cfg_file_and_adds_a_target_file_s_path_to_the_config_file(self):
|
|
|
|
|
|
|
|
target_path = join_paths(
|
|
|
|
|
|
|
|
CHROOT_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_7')
|
|
|
|
|
|
|
|
output_path = os.path.join(os.path.dirname(target_path),
|
|
|
|
|
|
|
|
'._cfg0001_file_7')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parameters_object = ParametersContainer({'package': test_package_name,
|
|
|
|
|
|
|
|
'append': 'join',
|
|
|
|
|
|
|
|
'format': 'bind'})
|
|
|
|
|
|
|
|
template_text = 'section-name { parameter-2 no; }'
|
|
|
|
|
|
|
|
output_text =\
|
|
|
|
|
|
|
|
'section-name {\n parameter-1 yes;\n parameter-2 no;\n};\n'
|
|
|
|
|
|
|
|
template_wrapper = TemplateWrapper(
|
|
|
|
|
|
|
|
target_path,
|
|
|
|
|
|
|
|
parameters_object, FILE,
|
|
|
|
|
|
|
|
template_text=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)
|
|
|
|
|
|
|
|
assert os.path.exists(output_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert os.path.exists(join_paths(
|
|
|
|
|
|
|
|
CONFIG_ARCHIVE_PATH,
|
|
|
|
|
|
|
|
'/etc/append_join_file_testfiles/file_7'))
|
|
|
|
|
|
|
|
with open(template_wrapper.output_path, 'r') as output_file:
|
|
|
|
|
|
|
|
assert output_file.read() == output_text
|
|
|
|
|
|
|
|
|
|
|
|
def test_to_remove_changed_testfiles(self):
|
|
|
|
def test_to_remove_changed_testfiles(self):
|
|
|
|
shutil.rmtree(os.path.join(CHROOT_PATH, 'etc'))
|
|
|
|
shutil.rmtree(os.path.join(CHROOT_PATH, 'etc'))
|
|
|
|
|
|
|
|
shutil.rmtree(os.path.join(CHROOT_PATH,
|
|
|
|
|
|
|
|
'var/lib/calculate/config-archive'))
|
|
|
|