1
0
mirror of https://github.com/240596448/onec_codetemplate_parser.git synced 2025-11-23 21:34:39 +02:00
Files
onec_codetemplate_parser/tests/test_core.py

45 lines
1.7 KiB
Python
Raw Normal View History

2025-11-04 16:08:26 +03:00
from onec_codetemplate_parser import core, repository
from tests.common import check_files_sequential
2025-10-21 22:33:34 +03:00
2025-10-31 15:23:24 +03:00
class TestReadSkobkofile:
2025-10-21 22:33:34 +03:00
def test_00_test_file_exist(self, test_file_path):
assert test_file_path.exists()
def test_01_parse_eq_compile(self, test_data):
root = core.parser(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):
root = core.parser(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
2025-10-31 15:23:24 +03:00
class TestWriteToFiles:
2025-10-21 22:33:34 +03:00
2025-11-01 02:18:51 +03:00
def test_white_to_src(self, test_data, temp_src):
root = core.parser(test_data)
2025-11-04 16:08:26 +03:00
root.to_src(temp_src)
# TODO: добавить разные проверки для каждого файла
2025-10-21 22:33:34 +03:00
2025-11-01 02:18:51 +03:00
# assert folder_contains_files(temp_src), f"В папке нет ни одного файла {temp_src}"
# assert not folder_is_empty(temp_src), f"Папка src пустая {temp_src}"
2025-10-21 22:33:34 +03:00
# Проверка: есть ли папки
2025-11-04 16:08:26 +03:00
# dirs = [p for p in temp_src.iterdir() if p.is_dir()]
# assert len(dirs) == 1, f"Ожидалась 1 папка в src, получили {len(dirs)}"
# assert temp_src / "001.0_Надулич" in dirs, f"Папка 001.0_Надулич не найдена в {temp_src}"
2025-10-21 22:33:34 +03:00
d = temp_src / "001.0_Надулич" / "002.0_Комментарии"
2025-11-04 16:08:26 +03:00
if d.exists():
subfiles = list(p.name for p in repository.dir_items(d))
check_files_sequential(subfiles)