You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
3.1 KiB
84 lines
3.1 KiB
import pytest
|
|
import time
|
|
import os
|
|
from calculate.templates.template_processor import DirectoryProcessor
|
|
from calculate.templates.template_engine import Variables
|
|
|
|
|
|
TESTFILES_PATH = os.path.join(os.getcwd(), 'tests/templates/testfiles')
|
|
TEST_ROOT_PATH = os.path.join(TESTFILES_PATH, 'test_root/')
|
|
CL_CONFIG_PATH = os.path.join(TEST_ROOT_PATH, 'var/lib/calculate/config')
|
|
|
|
|
|
# Вместо модуля переменных.
|
|
group = Variables({'bool': True,
|
|
'list': [1, 2, 3]})
|
|
|
|
variables = Variables({'variable_1': 'value_1',
|
|
'variable_2': 'value_2',
|
|
'group': group})
|
|
|
|
install = Variables({'os_disk_dev': 'os_disk_dev_value',
|
|
'version': 1.5,
|
|
'number': 128,
|
|
'boolean': False,
|
|
'type': 'static',
|
|
'path': '/usr/sbin'})
|
|
|
|
merge = Variables({'var_1': 674,
|
|
'var_2': 48,
|
|
'version': 1.0,
|
|
'calculate_domains': 'lists.calculate-linux.org',
|
|
'ip_value': '127.0.0.0/8'})
|
|
|
|
main = Variables({'cl_template_path':
|
|
'{0},{1}'.format(os.path.join(TEST_ROOT_PATH,
|
|
'templates'),
|
|
os.path.join(TEST_ROOT_PATH,
|
|
'var/calculate/templates')),
|
|
'cl_chroot_path': TEST_ROOT_PATH,
|
|
'cl_config_path': CL_CONFIG_PATH,
|
|
'cl_ignore_files': '*.swp'})
|
|
|
|
test = ({'test_root': TEST_ROOT_PATH})
|
|
|
|
datavars = Variables({'install': install,
|
|
'merge': merge,
|
|
'variables': variables,
|
|
'main': main,
|
|
'test': test,
|
|
'custom': Variables()})
|
|
|
|
|
|
@pytest.mark.directory_processor
|
|
class TestDirectoryProcessor:
|
|
def test_just_for_debug_without_package_value(self):
|
|
# start_time = time.time()
|
|
try:
|
|
dir_processor = DirectoryProcessor(
|
|
'install',
|
|
datavars_module=datavars,
|
|
without_execution=True,
|
|
debug_mode=True)
|
|
dir_processor.process_template_directories()
|
|
except Exception as error:
|
|
pytest.fail('Unexpected exception: {}'.format(str(error)))
|
|
|
|
# print('time: {}'.format(time.time() - start_time))
|
|
|
|
def test_just_for_debug_with_package_value(self):
|
|
# start_time = time.time()
|
|
# try:
|
|
dir_processor = DirectoryProcessor(
|
|
'install',
|
|
package='xfce-extra/xfce4-pulseaudio-plugin',
|
|
datavars_module=datavars,
|
|
without_execution=True,
|
|
debug_mode=True)
|
|
dir_processor.process_template_directories()
|
|
# except Exception as error:
|
|
# pytest.fail('Unexpected exception: {}'.format(str(error)))
|
|
|
|
# print('time: {}'.format(time.time() - start_time))
|
|
# assert False
|