40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
|
|
import core # noqa: E402
|
|
from next_helpers import load_case_paths, make_case # noqa: E402
|
|
|
|
|
|
def test_every_tool_exists():
|
|
assert all(Path(argv[-1]).is_file() for argv in core.TOOLS.values())
|
|
|
|
|
|
def test_tool_argv_shapes():
|
|
assert Path(core.TOOLS["pdf_kit"][-1]).name == "pdf-kit.py"
|
|
assert core.TOOLS["scan_legal"][0] == "bash" and core.TOOLS["case_paths"][0] == sys.executable
|
|
|
|
|
|
# case_paths --selftest сюда не входит: см. README, раздел «Тесты».
|
|
@pytest.mark.parametrize("name", ["document_guard", "review_delta"])
|
|
def test_tool_selftest_green(name):
|
|
assert subprocess.run(core.TOOLS[name] + ["--selftest"], cwd=core.ROOT, capture_output=True, timeout=600).returncode == 0
|
|
|
|
|
|
def test_contract_matches_case_paths(tmp_path):
|
|
case = make_case(tmp_path / "cases" / "c" / "d")
|
|
c = core.contract(case, "iskovoe")
|
|
cp = load_case_paths() # importlib по пути ROOT/scripts/case_paths.py
|
|
assert c["draft_md"] == cp.drafts(case) / "iskovoe.md" and core.context(case) == cp.context(case)
|
|
assert c["ready_md"] == cp.ready(case) / "iskovoe.md" and c["ready_docx"] == cp.ready(case) / "iskovoe.docx"
|
|
assert c["review_rounds"] == cp.MAX_REVIEW_ROUNDS >= 1
|
|
|
|
|
|
def test_contract_of_relative_case_points_into_repo():
|
|
c = core.contract(Path("cases/c/d"), "iskovoe")
|
|
assert c["draft_md"] == core.ROOT / "cases/c/d/.agent/drafts/iskovoe.md"
|