报告开头改成重点摘要卡
新报告用围栏画出大运和事业、财富、婚恋,标题下写名字与日期。旧报告不变。 自测:pytest test_report_full_data_fix.py 10 通过;相关四份报告测试退出码 0;前端相关测试 147 通过、0 失败、0 取消;tsc 退出码 0;lint 0 error。 Co-Authored-By: Grok (agent loop)
This commit is contained in:
co-authored by
Grok (agent loop)
parent
963276ca2f
commit
8883f8475f
@@ -8,15 +8,18 @@ calculate a new dasha or import PyJHora.
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import json
|
||||
import re
|
||||
|
||||
from scripts.pl9_full_data_export import _sanitize_pl9_ai_density_markdown, render_full_data_markdown
|
||||
from scripts.pl9_interpretation_packs import (
|
||||
_current_lords,
|
||||
attach_full_data_interpretation,
|
||||
missing_field_count,
|
||||
opening_focus_block,
|
||||
section_coverage,
|
||||
)
|
||||
from scripts.report_focus_block import FOCUS_FENCE_RE, parse_focus_fence
|
||||
from scripts.pl9_reader_english import HAN
|
||||
|
||||
FORBIDDEN_ZH = (
|
||||
@@ -170,9 +173,15 @@ def test_templates_cover_required_sections_and_forbidden_wording() -> None:
|
||||
packet = _packet("zh")
|
||||
attach_full_data_interpretation(packet)
|
||||
focus = opening_focus_block(packet)
|
||||
assert focus.startswith("重点:")
|
||||
assert "MD" in focus and "AD" in focus and "PD" in focus
|
||||
assert "第10宫" in focus and "第2宫" in focus and "第7宫" in focus
|
||||
# 原值:focus.startswith("重点:"),并且正文含 MD / AD / PD。
|
||||
# 新值:开篇是「## 重点」加一个 jyotish-focus 围栏,不再写那一行行话。
|
||||
# 原因:产品选择把开篇做成摘要卡,围栏交给阅读页画,不在正文里堆 MD/AD/PD。
|
||||
assert focus.startswith("## 重点")
|
||||
assert "重点:当前主运" not in focus
|
||||
assert "MD " not in focus and "AD " not in focus and "PD " not in focus
|
||||
payload = parse_focus_fence(focus)
|
||||
assert payload is not None
|
||||
assert [row["house"] for row in payload["domains"]] == [10, 2, 7]
|
||||
text = render_full_data_markdown(packet)
|
||||
for heading in ("大运解释", "行星、星宿与宫位解释", "宫主逐宫解释", "Dosha 逐项事实与解释", "瑜伽解释"):
|
||||
assert heading in text
|
||||
@@ -194,7 +203,12 @@ def test_templates_cover_required_sections_and_forbidden_wording() -> None:
|
||||
def test_english_focus_and_new_sections_have_no_han() -> None:
|
||||
packet = _packet("en")
|
||||
text = render_full_data_markdown(packet)
|
||||
assert "Focus: current Maha Dasha MD" in text
|
||||
# 原值:正文含 "Focus: current Maha Dasha MD"。
|
||||
# 新值:英文开篇是「## Focus」加 jyotish-focus 围栏,不再写那一行。
|
||||
# 原因:与中文摘要卡同一结构;大运章里的 AD/PD 表头仍保留。
|
||||
assert "## Focus" in text
|
||||
assert "```jyotish-focus" in text
|
||||
assert "Focus: current Maha Dasha MD" not in text
|
||||
assert "AD" in text and "PD" in text
|
||||
assert "Dasha Interpretation" in text
|
||||
assert "House-lord interpretation" in text
|
||||
@@ -209,6 +223,60 @@ def test_english_focus_and_new_sections_have_no_han() -> None:
|
||||
assert leaked == [], leaked[:12]
|
||||
|
||||
|
||||
def _focus_dates(packet: dict, level: str) -> tuple[str | None, str | None]:
|
||||
dasha = packet["worksheets"]["timing_and_predictive_systems"]["dasha"]
|
||||
current = dasha["current_dasha"]
|
||||
if level == "md":
|
||||
return current.get("start"), current.get("end")
|
||||
for row in current["antardasha_timeline"]:
|
||||
if not row.get("is_current"):
|
||||
continue
|
||||
if level == "ad":
|
||||
return row.get("start"), row.get("end")
|
||||
for child in row["pratyantar_dasha_timeline"]:
|
||||
if child.get("is_current"):
|
||||
return child.get("start"), child.get("end")
|
||||
return None, None
|
||||
|
||||
|
||||
def test_opening_focus_fence_matches_current_lords_and_skips_the_fixed_list() -> None:
|
||||
for language in ("zh", "en"):
|
||||
packet = _packet(language)
|
||||
lords = _current_lords(packet)
|
||||
text = render_full_data_markdown(packet)
|
||||
fences = FOCUS_FENCE_RE.findall(text.split("## 结构化资料附录", 1)[0].split("## Structured Data Appendix", 1)[0])
|
||||
assert len(fences) == 1, language
|
||||
payload = json.loads(fences[0])
|
||||
assert payload["version"] == 1
|
||||
assert [row["level"] for row in payload["periods"]] == ["md", "ad", "pd"]
|
||||
assert [row["lord"] for row in payload["periods"]] == [lords["md"], lords["ad"], lords["pd"]]
|
||||
for row in payload["periods"]:
|
||||
start, end = _focus_dates(packet, row["level"])
|
||||
assert row["start"] == start
|
||||
assert row["end"] == end
|
||||
assert [row["key"] for row in payload["domains"]] == ["career", "wealth", "relationship"]
|
||||
assert [row["house"] for row in payload["domains"]] == [10, 2, 7]
|
||||
opening = text.split("## 出生资料", 1)[0].split("## Birth Data", 1)[0]
|
||||
assert "重点:当前主运" not in opening
|
||||
assert "先核对出生资料、图盘" not in text
|
||||
if language == "zh":
|
||||
assert "MD " not in opening and "AD " not in opening and "PD " not in opening
|
||||
assert "功能吉凶为功能吉星" not in opening
|
||||
assert payload["caveat"] == "这段时间可能突出这些宫主所守护的主题,不是确定会发生的事。"
|
||||
else:
|
||||
assert "Focus: current Maha Dasha" not in opening
|
||||
|
||||
|
||||
def test_opening_focus_keeps_null_when_a_period_has_no_date() -> None:
|
||||
packet = _packet("zh")
|
||||
packet["worksheets"]["timing_and_predictive_systems"]["dasha"]["current_dasha"]["antardasha_timeline"][0]["end"] = ""
|
||||
payload = parse_focus_fence(render_full_data_markdown(packet))
|
||||
assert payload is not None
|
||||
ad = next(row for row in payload["periods"] if row["level"] == "ad")
|
||||
assert ad["start"] == "2001-01-01"
|
||||
assert ad["end"] is None
|
||||
|
||||
|
||||
def test_yoga_effect_does_not_assert_lifespan() -> None:
|
||||
# 原值:作用列写「长寿;健康良好」/ Longevity。
|
||||
# 新值:作用列改成体质与恢复力的参考句。名称「长寿格局」和 Ayur Yoga (Strong Longevity) 可以留下。
|
||||
|
||||
Reference in New Issue
Block a user