Consultation was passing the birth mahadasha into event-class splits, so marriage hits stayed empty and timing still said 缔结. Read live MD/AD from dasha_sub_periods, derive activation copy from the split, and isolate fence failures so one bad varga cannot 500 the whole report. Co-authored-by: Cursor <cursoragent@cursor.com>
60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
"""Marriage timing copy follows event_class_split; missing AD is not spelled Unknown."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from scripts.report_orchestrator import BirthChartData, ThemeName, TimingAnchorBuilder
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
ORCHESTRATOR = ROOT / "scripts" / "report_orchestrator.py"
|
|
|
|
|
|
def _builder(split: dict, *, antardasha: str = "Unknown") -> TimingAnchorBuilder:
|
|
chart = BirthChartData(
|
|
dasha_timeline=[
|
|
{"mahadasha": "Saturn", "antardasha": antardasha, "start": 2025, "end": 2028},
|
|
],
|
|
event_class_split=split,
|
|
)
|
|
return TimingAnchorBuilder(chart)
|
|
|
|
|
|
def test_romantic_only_says_not_legal_marriage() -> None:
|
|
timing = _builder({"romantic_activation": {"hits": ["5L_dasha"]}}).build_for_theme(ThemeName.MARRIAGE)
|
|
assert timing is not None
|
|
assert "不等于领证" in timing.activation_description
|
|
assert "缔结" not in timing.activation_description
|
|
assert "关键期" not in timing.activation_description
|
|
|
|
|
|
def test_legal_md_ad_hit_may_say_solemnize() -> None:
|
|
timing = _builder(
|
|
{"legal_marriage": {"hits": ["Venus_dasha"]}},
|
|
antardasha="Venus",
|
|
).build_for_theme(ThemeName.MARRIAGE)
|
|
assert timing is not None
|
|
assert "缔结" in timing.activation_description
|
|
assert timing.dasha_period == "Saturn-Venus"
|
|
|
|
|
|
def test_no_hits_omits_key_period_and_solemnize() -> None:
|
|
timing = _builder({}).build_for_theme(ThemeName.MARRIAGE)
|
|
assert timing is not None
|
|
assert "关键期" not in timing.activation_description
|
|
assert "缔结" not in timing.activation_description
|
|
assert timing.activation_description == "本期无婚恋事件类命中"
|
|
assert "Unknown" not in timing.dasha_period
|
|
assert timing.dasha_period == "Saturn"
|
|
|
|
|
|
def test_legal_phrase_only_lives_on_the_legal_branch() -> None:
|
|
source = ORCHESTRATOR.read_text(encoding="utf-8")
|
|
assert source.count("缔结或调整伴侣关系的关键期") == 1
|
|
legal_fn = source[source.index("def _marriage_activation_text") :]
|
|
legal_fn = legal_fn[: legal_fn.index("class ThematicReportOrchestrator")]
|
|
assert "if legal_hits:" in legal_fn
|
|
before_legal, after_legal = legal_fn.split("if legal_hits:", 1)
|
|
assert "缔结或调整伴侣关系的关键期" not in before_legal
|
|
assert "缔结或调整伴侣关系的关键期" in after_legal.split("return", 1)[1].split("\n", 1)[0]
|