arm-core/api/tests/dbml_helpers.py
Andrey Epifancev 8e6223a273 feat: models/enums.py — 27 enum'ов DBML v5.13, фабрика pg_enum, DBML_VERSION
Тест сверяет имена и упорядоченные значения с блоками Enum {} DBML через pydbml.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-03 18:47:23 +04:00

25 lines
1012 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Поиск и разбор DBML-модели для тестов (переиспользуется тестами чётности ORM и DBML)."""
import os
from pathlib import Path
import pytest
from pydbml import PyDBML
DBML_FILE_NAME = "data-model-v5.13.dbml"
def dbml_path() -> Path:
"""Путь к DBML: каталог docs из `ARM_KA_DOCS`, иначе соседний `../../docs` относительно `arm-core/api`."""
docs = os.environ.get("ARM_KA_DOCS")
docs_dir = Path(docs) if docs else Path(__file__).resolve().parents[3] / "docs"
return docs_dir / "model" / DBML_FILE_NAME
def load_dbml() -> PyDBML:
"""Разобрать DBML через pydbml; без файла — пропуск теста с явной причиной."""
path = dbml_path()
if not path.is_file():
pytest.skip(f"docs недоступен: нет {path} (задайте ARM_KA_DOCS или положите docs рядом с arm-core)")
return PyDBML.parse_file(path)