From e09123ae180fac8d9548ecc51320ebec330d7a50 Mon Sep 17 00:00:00 2001 From: anor Date: Wed, 18 Nov 2026 02:37:58 +1000 Subject: [PATCH] =?UTF-8?q?test(=D0=A2=D0=A1=D0=9D):=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D0=B2=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BD=D0=BE=D1=80=D0=BC?= =?UTF-8?q?-=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D0=B2=20?= =?UTF-8?q?=D1=81=D0=BC=D0=B5=D1=82=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Code --- tests/test_tsn_verify_wiring.py | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/test_tsn_verify_wiring.py diff --git a/tests/test_tsn_verify_wiring.py b/tests/test_tsn_verify_wiring.py new file mode 100644 index 0000000..b1d1f56 --- /dev/null +++ b/tests/test_tsn_verify_wiring.py @@ -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("", 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("", 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"])