test(ТСН): проверки встраивания норм-проверки в смету
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
"""Норм-проверка встроена в проверку сметы (T10): Москва → ТСН, иначе честно молчит."""
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
if ROOT not in sys.path:
|
||||
sys.path.insert(0, ROOT)
|
||||
|
||||
import smeta_mcp # noqa: E402
|
||||
|
||||
|
||||
def test_schema_exposes_region():
|
||||
props = smeta_mcp.TOOLS["verify_estimate_file"]["inputSchema"]["properties"]
|
||||
assert {"region", "norm_base_value", "as_of"} <= set(props)
|
||||
|
||||
|
||||
def test_moscow_attaches_tsn_block(monkeypatch, tmp_path):
|
||||
gge = tmp_path / "s.gge"
|
||||
gge.write_text("<x/>", encoding="utf-8")
|
||||
|
||||
monkeypatch.setattr(smeta_mcp, "_locate", lambda d, f: gge)
|
||||
import gge_tools, estimate_verify, norm_base, tsn_verify
|
||||
monkeypatch.setattr(gge_tools, "parse_gge_file",
|
||||
lambda p: {"positions": [{"code": "1-5-1", "unit": "100 м3", "qty": 1}]})
|
||||
monkeypatch.setattr(estimate_verify, "from_gge_parsed", lambda p: [])
|
||||
monkeypatch.setattr(estimate_verify, "verify", lambda pos: {"errors": [], "warnings": [], "checked": 0, "ok": True})
|
||||
monkeypatch.setattr(estimate_verify, "verify_gge_summary", lambda t: {"errors": [], "checked": 0})
|
||||
monkeypatch.setattr(norm_base, "resolve",
|
||||
lambda meta, codes=None: {"status": "ok", "base": "ТСН-2001", "message": ""})
|
||||
monkeypatch.setattr(tsn_verify, "verify",
|
||||
lambda pos, base, as_of=None: {"ok": True, "checked": 1, "errors": [], "unchecked": []})
|
||||
r = smeta_mcp.tool_verify_estimate_file(filename="s.gge", region="г. Москва")
|
||||
assert r["tsn"]["checked"] == 1
|
||||
assert r["norm_base"]["base"] == "ТСН-2001"
|
||||
|
||||
|
||||
def test_disabled_base_warns_not_fakes(monkeypatch, tmp_path):
|
||||
gge = tmp_path / "s.gge"; gge.write_text("<x/>", encoding="utf-8")
|
||||
monkeypatch.setattr(smeta_mcp, "_locate", lambda d, f: gge)
|
||||
import gge_tools, estimate_verify, norm_base
|
||||
monkeypatch.setattr(gge_tools, "parse_gge_file",
|
||||
lambda p: {"positions": [{"code": "1-5-1", "unit": "100 м3", "qty": 1}]})
|
||||
monkeypatch.setattr(estimate_verify, "from_gge_parsed", lambda p: [])
|
||||
monkeypatch.setattr(estimate_verify, "verify", lambda pos: {"errors": [], "warnings": [], "checked": 0, "ok": True})
|
||||
monkeypatch.setattr(estimate_verify, "verify_gge_summary", lambda t: {"errors": [], "checked": 0})
|
||||
monkeypatch.setattr(norm_base, "resolve",
|
||||
lambda meta, codes=None: {"status": "tsn_disabled", "base": None,
|
||||
"message": "ТСН отключена"})
|
||||
r = smeta_mcp.tool_verify_estimate_file(filename="s.gge", region="г. Москва")
|
||||
assert "tsn" not in r
|
||||
assert any(w["rule"] == "норм-проверка не выполнялась" for w in r["warnings"])
|
||||
Reference in New Issue
Block a user