diff --git a/tests/templates/format/testfiles/a/dir/file1.txt b/tests/templates/format/testfiles/a/dir/file1.txt
index 023bd50..474f6f7 100644
--- a/tests/templates/format/testfiles/a/dir/file1.txt
+++ b/tests/templates/format/testfiles/a/dir/file1.txt
@@ -1,10 +1,17 @@
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_EXTABLE_SORT=y
+CONFIG_THREAD_INFO_IN_TASK=y
#
# General setup
#
+CONFIG_INIT_ENV_ARG_LIMIT=16
+# CONFIG_COMPILE_TEST is not set
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_BUILD_SALT=""
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
CONFIG_HAVE_KERNEL_XZ=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_HAVE_KERNEL_LZ4=y
diff --git a/tests/templates/format/testfiles/a/dir/file2.txt b/tests/templates/format/testfiles/a/dir/file2.txt
index be7bbc3..acfa977 100644
--- a/tests/templates/format/testfiles/a/dir/file2.txt
+++ b/tests/templates/format/testfiles/a/dir/file2.txt
@@ -8,3 +8,9 @@ A needle tears a hole
The old familiar sting
Try to kill it all away
But I remember everything.
+
+What have I become
+My sweetest friend
+Everyone I know
+Goes away
+In the end
diff --git a/tests/templates/format/testfiles/xml_gconf_result.xml b/tests/templates/format/testfiles/xml_gconf_result.xml
index 6b9c03b..3951a4d 100644
--- a/tests/templates/format/testfiles/xml_gconf_result.xml
+++ b/tests/templates/format/testfiles/xml_gconf_result.xml
@@ -17,15 +17,15 @@
-
+
distributor
-
-
+
+
diff --git a/tests/templates/test_template_executor.py b/tests/templates/test_template_executor.py
index d3f65a2..d079e1c 100644
--- a/tests/templates/test_template_executor.py
+++ b/tests/templates/test_template_executor.py
@@ -621,6 +621,8 @@ class TestTemplateExecutor:
def test_if_the_clear_directory_method_s_input_is_a_path_to_an_existing_empty_directory__the_method_does_nothing(self):
target_path = join_paths(CHROOT_PATH,
'/etc/clear_dir_testfiles/dir_0')
+ # Делаем директорию пустой.
+ os.remove(os.path.join(target_path, 'file'))
template_executor._clear_directory(target_path)
assert not os.listdir(target_path)
diff --git a/tests/templates/test_template_wrapper.py b/tests/templates/test_template_wrapper.py
index 996c351..ffabae1 100644
--- a/tests/templates/test_template_wrapper.py
+++ b/tests/templates/test_template_wrapper.py
@@ -673,19 +673,24 @@ class TestTemplateWrapper:
assert not template_wrapper.protected
def test_if_a_target_file_is_located_in_a_directory_from_the_protected_mask__the_TemplateWrapper_object_sets_the_protected_flag_as_False(self):
- parameters_object = ParametersContainer({'append': 'join',
- 'format': 'samba'})
- try:
- template_wrapper = TemplateWrapper(
- join_paths(CHROOT_PATH,
- '/etc/terminfo/info.json'),
- parameters_object, FILE,
- '/path/to/template',
- chroot_path=CHROOT_PATH,
- config_archive_path=CONFIG_ARCHIVE_PATH)
- except Exception as error:
- pytest.fail("Unexpected exception: {}".format(str(error)))
- assert not template_wrapper.protected
+ if os.environ.get('CONFIG_PROTECT', False):
+ parameters_object = ParametersContainer({'append': 'join',
+ 'format': 'samba'})
+ try:
+ template_wrapper = TemplateWrapper(
+ join_paths(CHROOT_PATH,
+ '/etc/terminfo/info.json'),
+ parameters_object, FILE,
+ '/path/to/template',
+ chroot_path=CHROOT_PATH,
+ config_archive_path=CONFIG_ARCHIVE_PATH)
+ except Exception as error:
+ pytest.fail("Unexpected exception: {}".format(str(error)))
+ print('PROTECTED SET')
+ print(template_wrapper._protected_set)
+ print('UNPROTECTED SET')
+ print(template_wrapper._unprotected_set)
+ assert not template_wrapper.protected
# Тестируем проверку хэш-сумм и флаг получаемый в результате нее.
def test_if_a_target_file_is_not_protected__the_TemplateWrapper_sets_the_md5_matching_flag_as_True(self):
diff --git a/tests/templates/testfiles/test_config_root_2/var/lib/calculate/config b/tests/templates/testfiles/test_config_root_2/var/lib/calculate/config
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_executor_root/etc.backup/append_clear_dir_testfiles/dir_0/file b/tests/templates/testfiles/test_executor_root/etc.backup/append_clear_dir_testfiles/dir_0/file
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_executor_root/etc.backup/append_join_dir_testfiles/dir_1/file b/tests/templates/testfiles/test_executor_root/etc.backup/append_join_dir_testfiles/dir_1/file
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_executor_root/etc.backup/append_join_file_testfiles/dir_16/file b/tests/templates/testfiles/test_executor_root/etc.backup/append_join_file_testfiles/dir_16/file
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_0/file b/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_0/file
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_1/file b/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_1/file
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_2/file b/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_2/file
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_3/file b/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_3/file
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_4/file b/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_4/file
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_5/file b/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_5/file
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_6/file b/tests/templates/testfiles/test_executor_root/etc.backup/append_link_dir_testfiles/dir_6/file
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_executor_root/etc.backup/append_remove_dir_testfiles/dir_2/file b/tests/templates/testfiles/test_executor_root/etc.backup/append_remove_dir_testfiles/dir_2/file
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_wrapper_root/etc/dir/dir_2/file b/tests/templates/testfiles/test_wrapper_root/etc/dir/dir_2/file
new file mode 100644
index 0000000..e69de29
diff --git a/tests/templates/testfiles/test_wrapper_root/var/db/pkg/test-category/test-package-1.0/CONTENTS b/tests/templates/testfiles/test_wrapper_root/var/db/pkg/test-category/test-package-1.0/CONTENTS
index aad0da2..a2ea5d3 100644
--- a/tests/templates/testfiles/test_wrapper_root/var/db/pkg/test-category/test-package-1.0/CONTENTS
+++ b/tests/templates/testfiles/test_wrapper_root/var/db/pkg/test-category/test-package-1.0/CONTENTS
@@ -6,6 +6,6 @@ obj /etc/dir/deleted.json 11e3a79fe51cce828d973dba8702adaa 1591356795
dir /etc/dir/subdir
obj /etc/dir/subdir/config.json 506649cf099878124deda2c2452c3693 1591605050
obj /etc/dir/subdir/file 84bcceb2c8e6de79849ea5f3304f2411 1591343236
-obj /etc/dir/file.conf 0b87fea7f5b65cac5012baa2bf647e72 1591196541
+obj /etc/dir/file.conf 0b87fea7f5b65cac5012baa2bf647e72 1594324832
dir /etc/dir/dir_1
-obj /etc/dir/dir_1/config.json 506649cf099878124deda2c2452c3693 1591617024
+obj /etc/dir/dir_1/config.json 506649cf099878124deda2c2452c3693 1594324832
diff --git a/tests/utils/test_files.py b/tests/utils/test_files.py
index 16e78d7..e93ed82 100644
--- a/tests/utils/test_files.py
+++ b/tests/utils/test_files.py
@@ -1,14 +1,19 @@
import pytest
+import os
from calculate.utils.files import Process
from subprocess import run, PIPE
+CHROOT_PATH = os.path.join(os.getcwd(), 'tests/utils/testfiles/')
+
+
@pytest.mark.files_utils
class TestUtils():
def test_if_single_correct_command_executed_using_Process_object__it_successfully_executes(self):
+ ls_path = os.path.join(CHROOT_PATH, 'etc')
try:
- ls_process = Process('ls', '-a', cwd='/')
- ls_result = run('ls -a', shell=True, stdout=PIPE, cwd='/')
+ ls_process = Process('ls', '-a', cwd=ls_path)
+ ls_result = run('ls -a', shell=True, stdout=PIPE, cwd=ls_path)
except Exception as error:
print('error:', str(error))
assert False
diff --git a/tests/utils/test_package.py b/tests/utils/test_package.py
index e4859fd..ec102bc 100644
--- a/tests/utils/test_package.py
+++ b/tests/utils/test_package.py
@@ -107,8 +107,10 @@ obj /usr/bin/vim 30acc0f256e11c1ecdb1bd80b688d238 1573538056
sym /usr/bin/vimdiff -> vim 1573538053
dir /etc
dir /etc/test_dir_2
-obj /etc/test_dir_2/file_2.cfg a371f4d456d471ac0ed0e8befff1cb6d 1586531028
-'''
+obj /etc/test_dir_2/file_2.cfg a371f4d456d471ac0ed0e8befff1cb6d {}
+'''.format(int(os.lstat(os.path.join(CHROOT_PATH,
+ 'etc/test_dir_2/file_2.cfg')).st_mtime))
+
contents_object.add_obj('/etc/test_dir_2/file_2.cfg')
print('RESULT:')
print(contents_object.render_contents_file())
@@ -125,8 +127,10 @@ obj /usr/bin/vim 30acc0f256e11c1ecdb1bd80b688d238 1573538056
sym /usr/bin/vimdiff -> vim 1573538053
dir /etc
dir /etc/test_dir_2
-sym /etc/test_dir_2/symlink -> file_2.cfg 1587117567
-'''
+sym /etc/test_dir_2/symlink -> file_2.cfg {}
+'''.format(int(os.lstat(os.path.join(CHROOT_PATH,
+ 'etc/test_dir_2/symlink')).st_mtime))
+
contents_object.add_sym('/etc/test_dir_2/symlink')
print('RESULT:')
print(contents_object.render_contents_file())