Keep consolidated costs out of local estimates and group public updates

This commit is contained in:
anor
2026-12-02 17:57:32 +10:00
parent 8630b76a55
commit 7c55cb3d36
11 changed files with 118 additions and 39 deletions
+11
View File
@@ -40,6 +40,17 @@ def test_resolved_draft_ok_and_computed():
assert not r["missing"]
def test_local_estimate_does_not_add_consolidated_costs_or_vat():
r = ec.build_and_calc(_draft(2), _resources(), _fgis())
assert r["grand_total"] == 4380.0
assert "grand_total_with_limits" not in r
assert "vat" not in r.get("totals", {})
assert "total_with_vat" not in r.get("totals", {})
assert "Нужен ли" in r["limits_note"]
assert "зимние" in r["limits_note"].lower()
assert "НДС" in r["limits_note"]
def test_metamorphic_qty_double():
r2 = ec.build_and_calc(_draft(2), _resources(), _fgis())
r4 = ec.build_and_calc(_draft(4), _resources(), _fgis())
+3 -1
View File
@@ -411,7 +411,9 @@ def test_пропавший_файл_цен_зоны_отказ_а_не_паде
def test_пометка_о_приморском_крае_не_выдаётся_самому_приморскому_краю(ec):
assert ec.calc_estimate(POS, {"region": "Приморский край"})["limits_note"] == ""
note = ec.calc_estimate(POS, {"region": "Приморский край"})["limits_note"]
assert "Нужен ли отдельный расчёт" in note
assert "Цены перевозок" not in note
assert "Приморскому краю" in ec.calc_estimate(POS, {"region": "г. Москва"})["limits_note"]
+7
View File
@@ -59,3 +59,10 @@ def test_ставка_ндс_названа_в_инструкции_агента
def test_ставка_ндс_названа_в_подсказке_справочного_пути():
текст = _read("claude_bridge_glm.py")
assert "Ставка НДС — 22 %" in текст, "в подсказке справочного пути нет действующей ставки НДС"
def test_локальная_смета_не_получает_дополнительные_затраты_без_запроса():
for name in ("claude_project_instructions.md", "claude_bridge_glm.py", "smeta_mcp.py"):
текст = _read(name)
assert "Локальная смета: не добавляй автоматически" in текст, name
assert "спроси, нужен ли отдельный расчёт" in текст, name
+28 -7
View File
@@ -52,8 +52,28 @@ def test_counts_only_available_public_documents_and_orders_feed(tmp_path, monkey
result = public_documents.snapshot()
assert result["count"] == 3
assert [d["title"] for d in result["recent"]] == [
"ТСН: новый", "Письмо-индекс Минстроя", "ТСН: старый"]
assert [(d["source"], d["loaded"][1]) for d in result["recent"]] == [
("ТСН Москвы", "18.11.2026"), ("ФГИС ЦС", "01.11.2026"),
("ТСН Москвы", "01.10.2026")]
def test_one_batch_does_not_hide_other_document_updates(tmp_path, monkeypatch):
import ext_state
import public_documents
monkeypatch.setattr(ext_state, "ext_dir", lambda: tmp_path)
for i in range(5):
_tsn(tmp_path, f"batch-{i}", f"ТСН {i}", f"2026-11-17T18:44:{i:02d}Z")
_bim(tmp_path, "letter", "2026-11-14T17:04:17Z")
public_documents.clear_cache()
recent = public_documents.snapshot()["recent"]
assert len(recent) == 2
assert recent[0]["source"] == "ТСН Москвы"
assert "5" in recent[0]["title"]
assert recent[1]["source"] == "ФГИС ЦС"
assert "1" in recent[1]["title"]
assert "</span> <span class=\"public-doc-meta\">" in public_documents.render()
def test_public_markup_escapes_titles_and_has_honest_empty_state(tmp_path, monkeypatch):
@@ -66,8 +86,9 @@ def test_public_markup_escapes_titles_and_has_honest_empty_state(tmp_path, monke
assert "Документы пока не загружены" in html
assert 'id="public-gesn-norms">—<' in html
_tsn(tmp_path, "xss", '<img src=x onerror=alert(1)>', "2026-11-18T10:00:00Z")
_tsn(tmp_path, "xss", "Безопасный документ", "2026-11-18T10:00:00Z")
public_documents.clear_cache()
public_documents.snapshot()["recent"][0]["title"] = '<img src=x onerror=alert(1)>'
html = public_documents.render()
assert "&lt;img" in html
assert "<img" not in html
@@ -94,7 +115,7 @@ def test_homepage_renders_public_feed_without_login(tmp_path, monkeypatch):
response = TestClient(main.app).get("/?v=" + main.APP_VERSION)
assert response.status_code == 200
assert 'id="public-gesn-norms"' in response.text
assert "ТСН: опубликованный" in response.text
assert "Обновлено документов ТСН Москвы: 1" in response.text
assert "{{PUBLIC_DOCUMENTS}}" not in response.text
@@ -112,8 +133,8 @@ def test_isolated_stage_reads_only_exported_public_summary(tmp_path, monkeypatch
public_documents.clear_cache()
data = public_documents.snapshot()
assert data["count"] == 2
assert [doc["title"] for doc in data["recent"]] == [
"Общий норматив", "Письмо-индекс Минстроя"]
assert [(doc["source"], doc["loaded"][1]) for doc in data["recent"]] == [
("ТСН Москвы", "18.11.2026"), ("ФГИС ЦС", "17.11.2026")]
def test_counts_builtin_normative_literature_too(tmp_path, monkeypatch):
@@ -142,7 +163,7 @@ def test_counts_builtin_normative_literature_too(tmp_path, monkeypatch):
assert result["count"] == 3
assert result["norm_count"] == 2
assert 'id="public-gesn-norms">2<' in public_documents.render()
assert [doc["title"] for doc in result["recent"]] == ["ТСН"]
assert [doc["title"] for doc in result["recent"]] == ["Обновлено документов ТСН Москвы: 1"]
def test_all_normative_databases_have_separate_counters(tmp_path, monkeypatch):