Files
llm/tests/1c/test_resolve_fact_paths.py

54 lines
1.8 KiB
Python

from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT / "scripts"))
from resolve_1c_fact import load_json, resolve_from_snapshot # noqa: E402
SNAPSHOT = ROOT / "plugins" / "1c" / "metadata" / "examples" / "metadata.example.json"
def resolve(member: str | None = None, *, table_section: str | None = None) -> dict:
return resolve_from_snapshot(
load_json(SNAPSHOT),
snapshot_path=SNAPSHOT,
kind="Справочник",
object_name="Номенклатура",
member=member,
area="any",
table_section=table_section,
view="effective",
extension=None,
)
def test_object_result_has_canonical_path() -> None:
result = resolve()
assert result["exists"] is True
assert result["object"]["canonical_path"] == "Справочник.Номенклатура"
assert result["match"]["canonical_path"] == "Справочник.Номенклатура"
assert result["match"]["path_kind"] == "metadata_object"
def test_attribute_result_has_canonical_path() -> None:
result = resolve("Артикул")
assert result["exists"] is True
assert result["match"]["canonical_path"] == "Справочник.Номенклатура.Артикул"
assert result["match"]["path_kind"] == "metadata_member"
def test_tabular_section_attribute_has_context_path() -> None:
result = resolve("Цена", table_section="Цены")
assert result["exists"] is True
assert result["match"]["canonical_path"] == "Справочник.Номенклатура.Цены.Цена"
assert result["match"]["context_path"] == "Цены.Цена"
assert result["match"]["path_kind"] == "metadata_member"