Keep consolidated costs out of local estimates and group public updates
This commit is contained in:
@@ -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 "<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):
|
||||
|
||||
Reference in New Issue
Block a user