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/') # Вместо модуля переменных. 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}) 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