1
0
mirror of https://github.com/240596448/onec_codetemplate_parser.git synced 2025-11-23 21:34:39 +02:00
This commit is contained in:
Vladimir Nadulich
2025-10-31 23:35:15 +03:00
parent 76e00877e8
commit 62db1f15e2
2 changed files with 26 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
import re
from pathlib import Path
def check_files_sequential(files: list[str]):
@@ -14,3 +15,11 @@ def check_files_sequential(files: list[str]):
assert number == true_number, f"Пропущен номер: ожидаем {true_number}, получили {number}"
expected_number += 1
def folder_is_empty(path):
return len(list(Path(path).iterdir())) != 0
def folder_contains_files(path):
files = [f.name for f in Path(path).rglob('*') if f.is_file()]
return len(files) > 0

17
tests/test_api.py Normal file
View File

@@ -0,0 +1,17 @@
from onec_codetemplate_parser import parse_to_src, render_from_src
from tests.common import folder_is_empty, folder_contains_files
class Test_API:
def test_parse(self, test_file_path, temp_src):
"""Тест библиотеки: парсинг"""
parse_to_src(str(test_file_path), str(temp_src))
assert folder_is_empty(temp_src), f"Папка src пустая {temp_src}"
assert folder_contains_files(temp_src), f"В папке нет ни одного файла {temp_src}"
def test_render(self, temp_src, tmp_path):
"""Тест библиотеки: сборка"""
temp_file = tmp_path / "output.st"
render_from_src(str(temp_src), str(temp_file))
assert temp_file.exists(), f"Файл сборки не создан {temp_file}"