Include full normative library and stage public document summary
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Публичная витрина показывает только общий нормативный корпус."""
|
||||
"""Публичная витрина показывает нормативный корпус."""
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -36,16 +36,11 @@ def test_counts_only_available_public_documents_and_orders_feed(tmp_path, monkey
|
||||
incomplete = tmp_path / "snapshots" / "niac_tsn" / "collections" / "incomplete"
|
||||
incomplete.mkdir()
|
||||
(incomplete / "meta.json").write_text('{"title":"не загружен"}', encoding="utf-8")
|
||||
# Пользовательские файлы не могут попасть в публичную выборку.
|
||||
private = tmp_path / "users" / "secret"
|
||||
private.mkdir(parents=True)
|
||||
(private / "contract.pdf").write_bytes(b"private")
|
||||
|
||||
result = public_documents.snapshot()
|
||||
assert result["count"] == 3
|
||||
assert [d["title"] for d in result["recent"]] == [
|
||||
"ТСН: новый", "Письмо-индекс Минстроя", "ТСН: старый"]
|
||||
assert all("contract" not in str(d) for d in result["recent"])
|
||||
|
||||
|
||||
def test_public_markup_escapes_titles_and_has_honest_empty_state(tmp_path, monkeypatch):
|
||||
@@ -88,3 +83,42 @@ def test_homepage_renders_public_feed_without_login(tmp_path, monkeypatch):
|
||||
assert 'id="public-doc-count">1<' in response.text
|
||||
assert "ТСН: опубликованный" in response.text
|
||||
assert "{{PUBLIC_DOCUMENTS}}" not in response.text
|
||||
|
||||
|
||||
def test_isolated_stage_reads_only_exported_public_summary(tmp_path, monkeypatch):
|
||||
import ext_state
|
||||
import public_documents
|
||||
|
||||
source = tmp_path / "production"
|
||||
stage = tmp_path / "stage"
|
||||
_tsn(source, "public", "Общий норматив", "2026-11-18T10:00:00Z")
|
||||
_bim(source, "letter", "2026-11-17T10:00:00Z")
|
||||
public_documents.export_summary(source, stage / "landing_documents.json")
|
||||
|
||||
monkeypatch.setattr(ext_state, "ext_dir", lambda: stage)
|
||||
public_documents.clear_cache()
|
||||
data = public_documents.snapshot()
|
||||
assert data["count"] == 2
|
||||
assert [doc["title"] for doc in data["recent"]] == [
|
||||
"Общий норматив", "Письмо-индекс Минстроя"]
|
||||
|
||||
|
||||
def test_counts_builtin_normative_literature_too(tmp_path, monkeypatch):
|
||||
import ext_state
|
||||
import public_documents
|
||||
|
||||
ext = tmp_path / "ext"
|
||||
project = tmp_path / "norms"
|
||||
literature = project / "literature" / "methods"
|
||||
literature.mkdir(parents=True)
|
||||
(literature / "method.pdf").write_bytes(b"%PDF-1.4")
|
||||
(literature / "appendix.htm").write_text("нормы", encoding="utf-8")
|
||||
(literature / "notes.txt").write_text("не документ", encoding="utf-8")
|
||||
_tsn(ext, "tsn", "ТСН", "2026-11-18T10:00:00Z")
|
||||
monkeypatch.setattr(ext_state, "ext_dir", lambda: ext)
|
||||
monkeypatch.setenv("SMETA_PROJECT_DIR", str(project))
|
||||
public_documents.clear_cache()
|
||||
|
||||
result = public_documents.snapshot()
|
||||
assert result["count"] == 3
|
||||
assert [doc["title"] for doc in result["recent"]] == ["ТСН"]
|
||||
|
||||
Reference in New Issue
Block a user