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

test context

This commit is contained in:
Vladimir Nadulich
2025-11-04 20:34:03 +03:00
parent c094e5f0a1
commit e8cf7cb173
7 changed files with 127 additions and 72 deletions

View File

@@ -3,19 +3,19 @@ from tests.common import folder_is_empty
class Test_API:
def test_parse(self, test_file_path, temp_src):
def test_parse(self, file_path_spec, temp_src):
"""Тест библиотеки: парсинг"""
parse_to_src(str(test_file_path), str(temp_src))
if test_file_path.stat().st_size > 6:
assert folder_is_empty(temp_src), f"Папка src пустая {temp_src}"
parse_to_src(str(file_path_spec.path), str(temp_src))
if file_path_spec.level != 0:
assert not folder_is_empty(temp_src), f"Папка src пустая {temp_src}"
else:
assert not folder_is_empty(temp_src), f"Для пустого файла что-то распарсилось {temp_src}"
assert folder_is_empty(temp_src), f"Для пустого файла что-то распарсилось {temp_src}"
def test_render(self, test_file_path, temp_src, tmp_path):
def test_render(self, file_path, temp_src, tmp_path):
"""Тест библиотеки: сборка"""
parse_to_src(str(test_file_path), str(temp_src))
parse_to_src(str(file_path), str(temp_src))
temp_file = tmp_path / "output.st"
render_from_src(str(temp_src), str(temp_file))
assert temp_file.exists(), f"Файл сборки не создан {temp_file}"
assert test_file_path.read_text(encoding='utf-8-sig') == temp_file.read_text(encoding='utf-8-sig'), 'Собранный файл не совпадает с исходным'
assert file_path.read_text(encoding='utf-8-sig') == temp_file.read_text(encoding='utf-8-sig'), 'Собранный файл не совпадает с исходным'