smeta_mcp.tool_verify_estimate_file: parse .gge → estimate_verify + verify_gge_summary (ФОТ=ЗПраб+ЗПмаш, точное тождество Summary). Калибровка показала: реконструкция итога из позиций .gge невозможна (материалы отдельно) — честно проверяем коды+самосогласов.+дубли. claude_bridge: +verify_estimate_file и +find_expertise_remarks в allowedTools, mount estimate_verify.py+code_validator.py в Docker. Фикстура broken_totals.gge, 3 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
"""Срез 2.2: инструмент verify_estimate_file (проверка загруженной .gge).
|
|
|
|
Гоняет tool_verify_estimate_file на фикстуре с несуществующим кодом (99-…) и
|
|
рассогласованным ФОТ (Salary≠ЗПраб+ЗПмаш). SMETA_WORK_DIR указывает на fixtures.
|
|
"""
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
_FIX = Path(__file__).resolve().parent / "fixtures"
|
|
|
|
|
|
def _tool():
|
|
os.environ["SMETA_WORK_DIR"] = str(_FIX)
|
|
import importlib
|
|
import smeta_mcp
|
|
importlib.reload(smeta_mcp) # чтобы _work_dir увидел SMETA_WORK_DIR
|
|
return smeta_mcp
|
|
|
|
|
|
def test_broken_gge_reports_errors():
|
|
sm = _tool()
|
|
r = sm.tool_verify_estimate_file(filename="broken_totals.gge")
|
|
assert "error" not in r, r
|
|
assert r["ok"] is False
|
|
rules = " ".join(e["rule"] for e in r["errors"])
|
|
assert "не существует" in rules # код 99-01-001-01
|
|
assert "ФОТ ≠" in rules # 100 ≠ 60+30
|
|
fot = [e for e in r["errors"] if "ФОТ ≠" in e["rule"]][0]
|
|
assert fot["expected"] == 90.0 and fot["actual"] == 100.0
|
|
|
|
|
|
def test_missing_file():
|
|
sm = _tool()
|
|
r = sm.tool_verify_estimate_file(filename="net_takogo.gge")
|
|
assert "error" in r
|
|
|
|
|
|
def test_non_gge_rejected():
|
|
sm = _tool()
|
|
(_FIX / "dummy.txt").write_text("x", encoding="utf-8")
|
|
r = sm.tool_verify_estimate_file(filename="dummy.txt")
|
|
assert "error" in r and ".gge" in r["error"]
|
|
(_FIX / "dummy.txt").unlink()
|