Files
Jyotisha/tests/test_report_formation_note_2394.py
ClaudeandClaude Opus 5.5 8eee1536c1
Independent Staging Quality Gate / validate-python (push) Successful in 7m23s
Independent Staging Quality Gate / validate-frontend (push) Successful in 6m8s
Independent Staging Quality Gate / publish (push) Successful in 19m27s
fix(report): Raja rows formed with a 6/8/12 lordship show the engine's mixed-effect note (BUG-2394)
BUG-2392 writes formation_note_zh / formation_note_en on formed Raja rows
whose lords also rule 6, 8 or 12. The report now prints that note after the
status in the body yoga table, after the formation line on the yoga page,
and in the appendix table's formation cell. Also updates a stale assertion
from BUG-2367 (the PD-only cell in the house-lord column).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXp3RzgZVEpT1PXxkwHj
2026-11-26 04:49:05 +08:00

60 lines
3.6 KiB
Python

"""BUG-2394: the engine's modifier note on a formed Raja row (BUG-2392) reaches the report.
Public chart only (Barack Obama, AA) plus synthetic rows.
"""
from __future__ import annotations
from scripts import pl9_interpretation_packs as packs
from scripts.report_render import yoga_appendix_fields as fields
from tests.public_chart_reports import public_chart_reports
ROW = {"rule_id": "raja_mutual_aspect", "name": "Raja Yoga (Mutual Aspect)", "name_cn": "王者格局(互视)",
"planets": ["Mercury", "Saturn"], "category": "raja",
"formation_assessment": {"status": "formed_under_source"},
"formation_note_zh": "实际作用有利有弊:水星同时管第 6 宫。",
"formation_note_en": "Mixed in effect: Mercury also rules house 6."}
def test_appendix_formation_cell_carries_the_note() -> None:
assert fields.formation_text(ROW, "zh") == "按具名定义成立。实际作用有利有弊:水星同时管第 6 宫。"
assert fields.formation_text(ROW, "en") == "Formed under the named definition. Mixed in effect: Mercury also rules house 6."
plain = {k: v for k, v in ROW.items() if not k.startswith("formation_note")}
assert fields.formation_text(plain, "zh") == "按具名定义成立"
def test_yoga_page_formation_line_carries_the_note() -> None:
for language, expected in (("zh", "构型:按该格局的具名定义,条件满足。实际作用有利有弊:水星同时管第 6 宫。"),
("en", "Configuration: met under the yoga's named definition. Mixed in effect: Mercury also rules house 6.")):
pages = packs.build_yoga_interpretation_pack({"detected_yogas": [ROW]}, {}, set(), language=language)["pages"]
assert pages[0]["sections"]["formation"] == expected
def test_public_report_shows_the_note_in_body_page_and_appendix() -> None:
_packet, chinese, english = public_chart_reports("barack_obama_1961_aa")
assert chinese.count("实际作用有利有弊:水星同时管第 6 宫。") == 3
assert english.count("Mixed in effect: Mercury also rules house 6.") == 3
# The body table's status column keeps the fixed status words (BUG-2104); the note follows the effect text.
assert "按所选规则的形成条件成立;强度和结果另评。实际作用有利有弊" not in chinese
assert "权力地位;影响力;实际作用有利有弊:水星同时管第 6 宫。" in chinese
def test_her_module_stays_verbatim_and_our_render_drops_the_source_line() -> None:
"""BUG-2394: BUG-2366 / 2381 / 2382 live in expression_paths_wiring, her renderer is untouched."""
from scripts.report_render.expression_paths_wiring import render_paths
from scripts.yoga_expression_paths import render_expression_paths
pack = {"rows": [{"kind": "x", "topic": "career", "title": {"en": "T", "zh": "T"}, "state": "full",
"meaning": {"en": "M", "zh": "M"}, "scope": {"en": "S", "zh": "S"}, "facts": [{"en": "F", "zh": "F"}],
"boundary": {"en": "B", "zh": "B"}, "source": "Book 11.7.3(1)"}]}
for language in ("en", "zh"):
assert "11.7.3(1)" in render_expression_paths(pack, language)
ours = render_paths(pack, language)
assert "11.7.3(1)" not in ours and "来源:" not in ours and "Source: " not in ours
assert "\n\n\n" not in ours
def test_rule_texts_name_no_book() -> None:
"""BUG-2394: 「原书」 in her rule texts reads 「原规则」 in the report (BUG-2129)."""
from scripts.report_render.yoga_effect_gate import reader_text
assert reader_text("仅核对原书位置结构,不据此判断视力。", "zh") == "仅核对原规则位置结构,不据此判断视力。"