feat(skill): merge upstream reader-report contract
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
"""Reader-report and commercial Skill import contracts."""
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from scripts.report_orchestrator import render_reader_report
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def test_render_reader_report_defaults_to_collapsed_appendix_and_keeps_order() -> None:
|
||||
rendered = render_reader_report({
|
||||
"thematic_narrative": {"career": {"text": "Provided narrative"}},
|
||||
"evidence_appendix": {"raw_data": {"Sun": 12.3}},
|
||||
"executive_summary": {"headline": "Provided summary"},
|
||||
})
|
||||
assert list(rendered) == ["presentation_mode", "executive_summary", "thematic_narrative", "evidence_appendix"]
|
||||
assert rendered["presentation_mode"] == "default"
|
||||
assert rendered["evidence_appendix"]["expanded"] is False
|
||||
|
||||
|
||||
def test_render_reader_report_expands_only_research_and_preserves_extensions() -> None:
|
||||
rendered = render_reader_report({
|
||||
"presentation_mode": "research",
|
||||
"executive_summary": {"title": "Research"},
|
||||
"thematic_narrative": {},
|
||||
"evidence_appendix": {"raw_data": {"Moon": 3.4}},
|
||||
"commercial_extension": {"health": True},
|
||||
})
|
||||
assert list(rendered) == [
|
||||
"presentation_mode", "executive_summary", "thematic_narrative", "evidence_appendix", "commercial_extension",
|
||||
]
|
||||
assert rendered["evidence_appendix"]["expanded"] is True
|
||||
assert rendered["commercial_extension"] == {"health": True}
|
||||
|
||||
|
||||
def test_upstream_skill_snapshot_matches_manifest_and_commercial_root_remains_router() -> None:
|
||||
snapshot = ROOT / "references/upstream/yinduzhanxing/SKILL.md"
|
||||
manifest = json.loads((snapshot.parent / "source-manifest.json").read_text(encoding="utf-8"))
|
||||
root_skill = (ROOT / "SKILL.md").read_text(encoding="utf-8")
|
||||
linked_skill = ROOT / "skills/jyotish-vedic-astrology/SKILL.md"
|
||||
|
||||
assert hashlib.sha256(snapshot.read_bytes()).hexdigest() == manifest["skill_sha256"]
|
||||
assert manifest["source_mode"] == "snapshot"
|
||||
assert manifest["source_commit"] is None
|
||||
assert linked_skill.resolve() == (ROOT / "SKILL.md").resolve()
|
||||
assert "商业运行时路由(最高优先级)" in root_skill
|
||||
assert "references/upstream/yinduzhanxing/SKILL.md" in root_skill
|
||||
assert "consumer_context.answer_policy" in root_skill
|
||||
assert "executive_summary -> thematic_narrative -> evidence_appendix" in root_skill
|
||||
assert (ROOT / "SKILL.md").read_bytes() != snapshot.read_bytes()
|
||||
Reference in New Issue
Block a user