Files
Jyotisha/tests/test_report_dasha_reference.py
T
ClaudeandClaude Opus 5.5 223c90ca0c
Independent Staging Quality Gate / validate-frontend (push) Successful in 6m20s
Independent Staging Quality Gate / validate-python (push) Successful in 7m37s
Independent Staging Quality Gate / publish (push) Successful in 2m47s
fix(report): drop the remaining 「来源」 lines and print birth-data source codes as reader words (BUG-2115 follow-up)
Annual clock captions no longer end with "this report's native calculation";
the general dasha reference drops its per-lord study-notes citation; the birth
data section translates user_reported / family_exact and the other stored codes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXp2U3BH1SxwAGyhhbe1
2026-11-21 11:35:24 +08:00

69 lines
3.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""「大运传统参考」 from the astrologer's bilingual text (yinduzhanxing 058c4f5f).
Policy (references/mahadasha_editorial_policy.md): three paragraphs side by
side, never picked by lord name; no diagnosis, lifespan or certainty words;
English edition fully English; Mahadasha layer only; the secondary source is
labelled as such.
"""
from __future__ import annotations
import json
import re
from pathlib import Path
from scripts.report_render.dasha_reference import insert_dasha_reference, load_reference, render_dasha_reference
ROOT = Path(__file__).resolve().parents[1]
FORBIDDEN_ZH = ("疾病", "必然", "一定会", "死亡", "你正在受克", "受克")
FORBIDDEN_EN = ("disease", "inevitable", "guarantee", "death")
def test_the_synced_text_has_nine_lords_three_paragraphs_each() -> None:
data = json.loads((ROOT / "references/mahadasha_editorial_bilingual.json").read_text(encoding="utf-8"))
assert data["personalized"] is False and data["upstream_reproduction"] is False
assert [planet["id"] for planet in data["planets"]] == ["Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn", "Rahu", "Ketu"]
for planet in data["planets"]:
kinds = [item["kind"] for item in planet["paragraphs"]]
assert kinds == ["general", "supportive_conditions", "strained_conditions"], planet["id"]
for item in planet["paragraphs"]:
assert item["zh"].strip() and item["en"].strip()
assert isinstance(item["pdf_page"], int)
def test_chinese_chapter_lists_all_three_paragraphs_and_labels_the_source() -> None:
text = render_dasha_reference("zh")
assert text.startswith("## 大运传统参考(通用)")
assert text.count("\n### ") == 9
for label in ("**一般背景**:", "**传统有利条件下**:", "**传统压力条件下**:"):
assert text.count(label) == 9
# 原值:每颗主星下一行「来源:《BPHS 读书笔记》…(二手资料;原典印刷版待核)」,共 9 行
# 新值:不写来源行
# 原因:BUG-2115 负责人 2026-11-21:报告里不给读者出现「来源」行;页码仍在数据文件里
assert "来源:" not in text and "原典印刷版待核" not in text
assert "不替这张盘做判断" in text and "不拼接小运" in text
for word in FORBIDDEN_ZH:
assert word not in text, word
def test_english_chapter_is_english_only() -> None:
text = render_dasha_reference("en")
assert text.startswith("## Traditional Dasha Reference (general)")
assert text.count("\n### ") == 9
assert not re.search(r"[一-鿿]", text)
# 原值:9 行 Source: BPHS Study Notes …
# 新值:不写来源行
# 原因:BUG-2115 负责人 2026-11-21:报告里不给读者出现「来源」行;页码仍在数据文件里
assert "Source:" not in text and "pending verification" not in text
lowered = text.lower()
for word in FORBIDDEN_EN:
assert word not in lowered, word
def test_the_chapter_follows_the_dasha_interpretation_chapter() -> None:
markdown = "# 报告\n\n## 大运解释\n\n正文\n\n## 星座大运(本站计算)\n\n表\n"
out = insert_dasha_reference(markdown, "zh")
assert out.index("## 大运解释") < out.index("## 大运传统参考(通用)") < out.index("## 星座大运(本站计算)")
assert insert_dasha_reference("# 报告\n\n## 其他\n", "zh") == "# 报告\n\n## 其他\n"
assert load_reference()["status"] == "secondary_source_editorial_reference"