exec and run parameters is not available for directory templates now.

master
Иванов Денис 4 years ago
parent 740c0a4d21
commit fb325a4669

@ -160,6 +160,8 @@ class ParametersProcessor:
'append': self.check_append_parameter,
'rebuild': self.check_rebuild_parameter,
'restart': self.check_restart_parameter,
'run': self.check_run_parameter,
'exec': self.check_exec_parameter,
'stop': self.check_stop_parameter,
'start': self.check_start_parameter,
'chown': self.check_chown_parameter,
@ -366,7 +368,7 @@ class ParametersProcessor:
def check_run_parameter(self, parameter_value):
if self.template_type == DIR:
raise IncorrectParameter("'run' parameter is not available in"
" directory templates.")
" directory templates")
if not parameter_value and isinstance(parameter_value, bool):
raise IncorrectParameter("'run' parameter value is empty")
try:
@ -379,7 +381,7 @@ class ParametersProcessor:
def check_exec_parameter(self, parameter_value):
if self.template_type == DIR:
raise IncorrectParameter("'exec' parameter is not available in"
" directory templates.")
" directory templates")
if not parameter_value and isinstance(parameter_value, bool):
raise IncorrectParameter("'exec' parameter value is empty")
try:

@ -1008,20 +1008,17 @@ class TestDirectoryProcessor:
assert directory_processor.template_executor.\
changed_files == {}
# def test_if_templates_contain_a_directory_with_a_calculate_directory_file_with_the_run_parameter_and_a_correct_script___the_directory_processor_runs_the_script_using_the_interpreter_from_the_run_parameter(self):
# datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH,
# 'templates_30')
# directory_processor = DirectoryProcessor('install',
# datavars_module=datavars)
# directory_processor.process_template_directories()
# # Скрипт создает файл.
# assert os.path.exists(join_paths(CHROOT_PATH, 'etc/file_14'))
# # Из скрипта не получить список файлов измененных или созданных
# # шаблоном.
# assert directory_processor.template_executor.\
# changed_files == {}
def test_if_templates_contain_a_directory_with_a_calculate_directory_file_with_the_run_parameter_and_a_correct_script___the_directory_processor_runs_the_script_using_the_interpreter_from_the_run_parameter(self):
datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH,
'templates_30')
directory_processor = DirectoryProcessor('install',
datavars_module=datavars)
directory_processor.process_template_directories()
# Скрипт создает файл.
assert not os.path.exists(join_paths(CHROOT_PATH, 'etc/file_14'))
assert directory_processor.template_executor.\
changed_files == {}
def test_if_templates_contain_some_files_with_the_exec_parameter_and_a_correct_scripts___the_directory_processor_saves_all_the_scripts_in_the_special_execute_directory_and_runs_all_the_files_after_all_templates_are_joined_and_packages_from_the_merge_parameter_is_processed(self):
datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH,

@ -0,0 +1,3 @@
{% calculate append = 'skip', run = '/usr/bin/python' %}
with open('./file_14', 'w') as output:
output.write("Where is my mind")
Loading…
Cancel
Save