2025-10-30 01:23:37 +03:00
|
|
|
from onec_codetemplate_parser import core
|
2025-10-21 22:33:34 +03:00
|
|
|
from tests.common import check_files_sequential
|
|
|
|
|
|
|
|
|
|
class Test_Read_Skobkofile:
|
|
|
|
|
|
|
|
|
|
def test_00_test_file_exist(self, test_file_path):
|
|
|
|
|
assert test_file_path.exists()
|
|
|
|
|
|
|
|
|
|
def test_01_parse_eq_compile(self, test_data):
|
2025-10-30 01:23:37 +03:00
|
|
|
root = core.parse_skobkofile(test_data)
|
2025-10-21 22:33:34 +03:00
|
|
|
new_data = root.compile()
|
|
|
|
|
assert new_data == test_data
|
|
|
|
|
|
|
|
|
|
def test_02_save_and_read(self, test_data, tmp_path):
|
2025-10-30 01:23:37 +03:00
|
|
|
root = core.parse_skobkofile(test_data)
|
2025-10-21 22:33:34 +03:00
|
|
|
new_data = root.compile()
|
|
|
|
|
|
|
|
|
|
tmp_file = tmp_path / 'tmp.st'
|
|
|
|
|
tmp_file.write_text(new_data, encoding='utf-8-sig')
|
|
|
|
|
new_data = tmp_file.read_text(encoding='utf-8-sig')
|
|
|
|
|
assert new_data == test_data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Test_Write_To_Files:
|
|
|
|
|
|
|
|
|
|
def test_00_to_file(self, test_data, temp_src):
|
2025-10-30 01:23:37 +03:00
|
|
|
root = core.parse_skobkofile(test_data)
|
2025-10-21 22:33:34 +03:00
|
|
|
root.to_files(temp_src)
|
|
|
|
|
|
|
|
|
|
def test_01_to_files(self, temp_src):
|
|
|
|
|
# Проверка: есть ли файлы
|
|
|
|
|
files = [p for p in temp_src.iterdir() if p.is_file()]
|
|
|
|
|
assert len(files) == 0
|
|
|
|
|
|
|
|
|
|
# Проверка: есть ли папки
|
|
|
|
|
dirs = [p for p in temp_src.iterdir() if p.is_dir()]
|
|
|
|
|
assert len(dirs) == 1
|
|
|
|
|
assert (temp_src / "001.0_Надулич") in dirs
|
|
|
|
|
|
|
|
|
|
def test_02_sequential_name(self, temp_src):
|
|
|
|
|
d = temp_src / "001.0_Надулич" / "002.0_Комментарии"
|
2025-10-30 01:23:37 +03:00
|
|
|
subfiles = [p.name for p in d.iterdir()]
|
2025-10-21 22:33:34 +03:00
|
|
|
check_files_sequential(subfiles)
|
|
|
|
|
|
|
|
|
|
|