You've already forked onec_codetemplate_parser
mirror of
https://github.com/240596448/onec_codetemplate_parser.git
synced 2025-11-23 21:34:39 +02:00
test api
This commit is contained in:
@@ -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
17
tests/test_api.py
Normal 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}"
|
||||
Reference in New Issue
Block a user