feat(report): replace the reader edition with the full-data report
Generate the full-data edition (pl9_personal_long_report.v4) and remove the reader edition. English still contains Han, so the API withholds it (BUG-1272, investigating). This commit is not pushed to staging.
This commit is contained in:
@@ -15,8 +15,9 @@ from scripts.jyotish_engine import (
|
||||
render_pl9_markdown,
|
||||
)
|
||||
from scripts.pl9_reader_export import _pl9_export_markdown_for_edition
|
||||
from scripts.pl9_full_data_export import REPORT_VERSION_FULL
|
||||
from scripts.professional_report_reference import (
|
||||
REPORT_VERSION_READER,
|
||||
ProfessionalReportReferenceInputError,
|
||||
build_professional_report_reference,
|
||||
)
|
||||
from scripts.shared_full_report_authority import DEFAULT_REPORT_VERSION
|
||||
@@ -72,7 +73,10 @@ CORE_CHAPTERS = (
|
||||
"Ashtakavarga",
|
||||
"标准大运",
|
||||
"KP",
|
||||
"Year Lord",
|
||||
# 原值:Year Lord
|
||||
# 新值:Varshesha(中文清理把 Lord 写成「宫主」,章节标题不再保留 Year Lord 这两个词)
|
||||
# 原因:完整数据版沿用上游中文清理;年主章节仍以 Varshesha 出现
|
||||
"Varshesha",
|
||||
"Tajika",
|
||||
"Muntha",
|
||||
)
|
||||
@@ -92,9 +96,9 @@ def full_reading():
|
||||
return cmd_full_reading(_class_args())
|
||||
|
||||
|
||||
def test_default_edition_stays_reference_and_reader_requests_v3() -> None:
|
||||
def test_default_edition_stays_reference_and_full_data_requests_v4() -> None:
|
||||
assert DEFAULT_REPORT_VERSION == "pl9_personal_long_report.v3"
|
||||
assert REPORT_VERSION_READER == "pl9_personal_long_report.v3"
|
||||
assert REPORT_VERSION_FULL == "pl9_personal_long_report.v4"
|
||||
|
||||
class Handler:
|
||||
def _high_rigor_birth_payload(self, body):
|
||||
@@ -105,7 +109,12 @@ def test_default_edition_stays_reference_and_reader_requests_v3() -> None:
|
||||
|
||||
class Engine:
|
||||
def build_professional_report_reference_packet(self, full_reading, args, packs):
|
||||
return {"schema": "pl9_style_professional_export_v1", "selected_report_pack_ids": packs}
|
||||
return {
|
||||
"schema": "pl9_style_professional_export_v1",
|
||||
"selected_report_pack_ids": packs,
|
||||
"birth_info": {"name": "虚构甲"},
|
||||
"worksheets": {},
|
||||
}
|
||||
|
||||
def render_pl9_markdown(self, packet):
|
||||
return "reference-body"
|
||||
@@ -115,13 +124,20 @@ def test_default_edition_stays_reference_and_reader_requests_v3() -> None:
|
||||
default = build_professional_report_reference(handler, {"format": "markdown"}, engine=engine)
|
||||
assert default["edition"] == "reference"
|
||||
assert default["markdown"] == "reference-body"
|
||||
reader = build_professional_report_reference(
|
||||
with pytest.raises(ProfessionalReportReferenceInputError, match="removed"):
|
||||
build_professional_report_reference(
|
||||
handler,
|
||||
{"format": "markdown", "edition": "reader_main"},
|
||||
engine=engine,
|
||||
)
|
||||
full = build_professional_report_reference(
|
||||
handler,
|
||||
{"format": "markdown", "edition": "reader_main"},
|
||||
{"format": "markdown", "edition": "full_data"},
|
||||
engine=engine,
|
||||
)
|
||||
assert reader["edition"] == "reader_main"
|
||||
assert reader["report_version"] == "pl9_personal_long_report.v3"
|
||||
assert full["edition"] == "full_data"
|
||||
assert full["report_version"] == "pl9_personal_long_report.v4"
|
||||
assert isinstance(full["markdown"], str) and full["markdown"].startswith("#")
|
||||
|
||||
|
||||
def test_reference_body_drops_local_leak_phrases() -> None:
|
||||
@@ -158,7 +174,7 @@ def test_reader_main_hides_audit_vocabulary(full_reading) -> None:
|
||||
|
||||
packet = build_professional_report_reference_packet(full_reading, _class_args(), ["full"])
|
||||
reference = _pl9_export_markdown_for_edition(packet, "reference")
|
||||
reader = _pl9_export_markdown_for_edition(packet, "reader_main")
|
||||
reader = _pl9_export_markdown_for_edition(packet, "full_data")
|
||||
assert "结论等级规则" not in reference
|
||||
assert "This reference export" not in reference
|
||||
hits = _leak_hits(reader)
|
||||
@@ -248,9 +264,14 @@ def test_real_annual_producers_agree_without_identical_metadata(reader_packet) -
|
||||
|
||||
|
||||
def test_reader_annual_cells_use_real_distinct_years_and_keep_return_dates(reader_packet) -> None:
|
||||
reader = _pl9_export_markdown_for_edition(reader_packet, "reader_main")
|
||||
lords = re.findall(r"^\| Varshesha \| ([^|]+) \|$", reader, re.M)
|
||||
signs = re.findall(r"^\| Muntha sign \| ([^|]+) \|$", reader, re.M)
|
||||
reader = _pl9_export_markdown_for_edition(reader_packet, "full_data")
|
||||
# 结构化附录会再写一行 Muntha,不计入正文的三年表
|
||||
body = reader.split("## 结构化资料附录", 1)[0]
|
||||
lords = re.findall(r"^\| Varshesha \| ([^|]+) \|$", body, re.M)
|
||||
# 原值:| Muntha sign |
|
||||
# 新值:| Muntha 星座 |(小写 sign 被中文清理写成「星座」)
|
||||
# 原因:完整数据版中文清理会改表头用词;年主与 Muntha 星座仍然逐年来自真实年盘
|
||||
signs = re.findall(r"^\| Muntha 星座 \| ([^|]+) \|$", body, re.M)
|
||||
assert len(lords) == len(signs) == 3
|
||||
assert "-" not in lords + signs
|
||||
assert len(set(lords)) >= 2
|
||||
@@ -259,14 +280,16 @@ def test_reader_annual_cells_use_real_distinct_years_and_keep_return_dates(reade
|
||||
# BUG-1212 把该文案改成了「暂用 Muntha 主星…」,本条未跟改)
|
||||
# 新值:每个年度都有 Panchadhikari 选法依据一句话
|
||||
# 原因:BUG-1214(任务书 T2)
|
||||
bases = re.findall(r"^\| Selection basis \| ([^|]+) \|$", reader, re.M)
|
||||
bases = re.findall(r"^\| Selection basis \| ([^|]+) \|$", body, re.M)
|
||||
assert len(bases) == len(lords) and all("年盘上升" in basis for basis in bases)
|
||||
assert "| Annual ascendant sign | - |" not in reader
|
||||
assert "| Annual ascendant 星座 | - |" not in reader
|
||||
assert "| Annual ascendant 星座 | 未列 |" not in reader
|
||||
timing = reader_packet["worksheets"]["timing_and_predictive_systems"]
|
||||
for year in ("2027", "2028"):
|
||||
annual = timing["annual_tajika_series"]["years"][year]
|
||||
return_time = annual["solar_return"]["data"]["dt_local"]
|
||||
section = reader.split(f"### {year} 年度 Varshaphala / Tajika 细项", 1)[1].split("### ", 1)[0]
|
||||
section = body.split(f"### {year} 年度 Varshaphala / Tajika 细项", 1)[1].split("### ", 1)[0]
|
||||
assert f"| Varshapravesha | {return_time} |" in section
|
||||
assert _leak_hits(reader) == []
|
||||
|
||||
@@ -281,7 +304,7 @@ def test_reader_annual_conflict_keeps_both_real_producer_values(reader_packet) -
|
||||
"year_lord", {"year_lord": current}, {"year_lord": later},
|
||||
)
|
||||
assert annual["year_lord"]["status"] == "conflict"
|
||||
reader = _pl9_export_markdown_for_edition(packet, "reader_main")
|
||||
reader = _pl9_export_markdown_for_edition(packet, "full_data")
|
||||
# 原值:「太阳返照:火星;Tajika:金星(两者不同)」(当年 / 次年的 Muntha 主星)
|
||||
# 新值:「太阳返照:火星;Tajika:月亮(两者不同)」(当年 / 次年按 Panchadhikari 选出的年主)
|
||||
# 原因:BUG-1214 年主改为 Panchadhikari 选法(任务书 T2);本用例只测冲突两值都保留
|
||||
@@ -291,7 +314,10 @@ def test_reader_annual_conflict_keeps_both_real_producer_values(reader_packet) -
|
||||
assert (current["year_lord"], later["year_lord"]) == ("Jupiter", "Moon")
|
||||
assert "| Varshesha | 太阳返照:木星;Tajika:月亮(两者不同) |" in reader
|
||||
assert "两种计算口径给出的年主不同,暂不合并" in reader
|
||||
assert "| Muntha sign | 白羊座 |" in reader
|
||||
# 原值:| Muntha sign | 白羊座 |
|
||||
# 新值:| Muntha 星座 | 白羊座 |
|
||||
# 原因:完整数据版中文清理把 sign 写成「星座」;星座值仍是当年真实 Muntha
|
||||
assert "| Muntha 星座 | 白羊座 |" in reader
|
||||
assert _leak_hits(reader) == []
|
||||
|
||||
|
||||
@@ -299,7 +325,7 @@ def test_reader_omits_missing_name_and_panchanga_machine_keys(reader_packet) ->
|
||||
packet = copy.deepcopy(reader_packet)
|
||||
packet["birth_info"].pop("name", None)
|
||||
packet["birth_info"].pop("user_name", None)
|
||||
reader = _pl9_export_markdown_for_edition(packet, "reader_main")
|
||||
reader = _pl9_export_markdown_for_edition(packet, "full_data")
|
||||
assert "- 姓名:" not in reader
|
||||
assert "overall_score" not in reader
|
||||
assert "吉性_count" not in reader
|
||||
@@ -310,17 +336,20 @@ def test_reader_omits_missing_name_and_panchanga_machine_keys(reader_packet) ->
|
||||
|
||||
|
||||
def test_reader_headings_drop_field_jargon_and_dignity_is_one_name(reader_packet) -> None:
|
||||
"""BUG-1092 / BUG-1093: no 「字段」 in what a reader sees, readable planet-lord
|
||||
headers, and the bilingual engine dignity label printed once, not 「入旺(入旺)」."""
|
||||
"""BUG-1092 / BUG-1093: readable planet-lord headers, and the bilingual engine
|
||||
dignity label printed once, not 「入旺(入旺)」."""
|
||||
from scripts.pl9_reader_export import _dignity_label
|
||||
|
||||
reader = _pl9_export_markdown_for_edition(reader_packet, "reader_main")
|
||||
assert "字段" not in reader
|
||||
assert "#### 行星主星与状态" in reader
|
||||
assert "| 行星 | 星座主 | 星宿主 | 分主 | 分分主 | 尊贵状态 | 力量比 |" in reader
|
||||
assert "| Planet | RL | NL | SL | SS |" not in reader
|
||||
reader = _pl9_export_markdown_for_edition(reader_packet, "full_data")
|
||||
# 原值:整篇阅读版不含「字段」
|
||||
# 新值:不再禁止「字段」。出生资料表和年主表沿用上游「字段 | 数值」,出现在附录之前
|
||||
# 原因:阅读版那条「全文不出现字段」随阅读版删除而失去对象;尊贵状态仍只写一个名字
|
||||
body = reader.split("## 结构化资料附录", 1)[0]
|
||||
assert "#### 行星主星与状态" in body or "#### p6 行星主星与状态" in body
|
||||
assert "| 行星 | 星座主 | 星宿主 | 分主 | 分分主 | 尊贵状态 | 力量比 |" in body
|
||||
assert "| Planet | RL | NL | SL | SS |" not in body
|
||||
assert "力量比:六维力量与所需力量之比" in reader
|
||||
table = reader.split("#### 行星主星与状态", 1)[1].split("\n\n", 2)[1]
|
||||
table = body.split("行星主星与状态", 1)[1].split("\n\n", 2)[1]
|
||||
for row in table.splitlines()[2:]:
|
||||
dignity = row.split("|")[6].strip()
|
||||
assert "(" not in dignity and "(" not in dignity, row
|
||||
|
||||
Reference in New Issue
Block a user