Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXp2U3BH1SxwAGyhhbe1
62 lines
3.9 KiB
Python
62 lines
3.9 KiB
Python
"""占星师 2026-11-23 一楠回归验收:细运、Yoga 周期关联、落陷三层(BUG-2260–2262)。只用虚构盘。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import json
|
||
|
||
import pytest
|
||
|
||
from scripts import pl9_interpretation_packs as packs
|
||
from scripts.report_render import reading_facts
|
||
|
||
|
||
def test_an_unusable_pd_reaches_the_reading_as_a_reason_only(monkeypatch) -> None:
|
||
"""BUG-2260: the reading may not judge by a PD the tables leave out."""
|
||
monkeypatch.setattr(reading_facts, "_pd_usable", lambda _packet: (False, "细运稳定性未评估(没有出生时间的误差范围),细运不参与判断"))
|
||
packet = {}
|
||
current = {"lord": "Saturn", "start": "2018-05-26", "end": "2037-05-25", "antardasha_timeline": [{
|
||
"lord": "Venus", "start": "2025-03-16", "end": "2028-05-16", "is_current": True,
|
||
"pratyantar_dasha_timeline": [{"lord": "Jupiter", "start": "2026-10-25", "end": "2027-03-28", "is_current": True}],
|
||
}]}
|
||
monkeypatch.setattr(reading_facts, "dig", lambda _packet, path: current if path == reading_facts.DASHA else None)
|
||
dates = reading_facts._vimshottari(packet)
|
||
assert dates["pratyantardasha"] == {"used": False, "not_used_zh": "细运稳定性未评估(没有出生时间的误差范围),细运不参与判断"}
|
||
assert "Jupiter" not in json.dumps(dates["pratyantardasha"])
|
||
assert dates["antardasha"]["lord"] == "Venus"
|
||
|
||
|
||
def test_classical_rows_carry_their_planets_from_the_engine() -> None:
|
||
"""BUG-2261 → BUG-2295: 「角宫主金星与三方宫主木星对宫互视」 overlaps a running Venus period. The row now records
|
||
its participants where it is computed (upstream f41efc51); the page no longer reads them from the text."""
|
||
raw = {"type": "Raj Yoga", "subtype": "mutual_aspect", "planets": ["Venus", "Jupiter"],
|
||
"combination": "Venus(角宫主) ↔ Jupiter(三方宫主)", "combination_zh": "角宫主金星与三方宫主木星对宫互视"}
|
||
pack = packs.build_yoga_interpretation_pack({}, {"raj_yogas": {"yogas": [raw]}}, {"Saturn", "Venus"}, language="zh")
|
||
text = json.dumps(pack, ensure_ascii=False)
|
||
assert "当前大运重叠:金星。" in text
|
||
assert not hasattr(packs, "_combination_planets")
|
||
from scripts.yogas_doshas import calc_raj_yogas
|
||
import inspect
|
||
assert inspect.getsource(calc_raj_yogas).count("'planets':") >= 5
|
||
|
||
|
||
def test_a_row_without_participants_is_not_called_unlinked() -> None:
|
||
pack = packs.build_yoga_interpretation_pack({}, {"raj_yogas": {"yogas": [{"type": "Sunapha", "combination_zh": "吉星在第2宫"}]}},
|
||
{"Saturn"}, language="zh")
|
||
text = json.dumps(pack, ensure_ascii=False)
|
||
assert "这一条没有返回参与的行星,没有判断它与当前大运的关系。" in text
|
||
|
||
|
||
@pytest.mark.parametrize("state, prefix, layer", [
|
||
# BUG-2280 原值 candidate「检测到的条件一」「核定:待核,所以全文写作「落陷;缓解条件待核」」、verified「核定:已按该规则核对」/
|
||
# 新值:两种状态同一句 / 原因:负责人 11-23,有缓解就写有缓解。
|
||
("candidate", "满足的条件一", "所以全文写作「落陷;有缓解」"),
|
||
("verified", "满足的条件一", "所以全文写作「落陷;有缓解」"),
|
||
])
|
||
def test_neecha_pages_say_the_three_layers_in_the_tables_state(state, prefix, layer) -> None:
|
||
"""BUG-2262: original dignity, conditions found, rule confirmation — never 「落陷取消」 in place of 落陷."""
|
||
roles = {"witnesses_returned": True, "conditions": [{"planet": "Jupiter"}], "self_reference_witnesses": []}
|
||
lines = packs._neecha_condition_lines(roles, "zh", lambda _item, _language: "落陷星座的主星木星照到落陷星", state)
|
||
assert lines.startswith(prefix)
|
||
assert layer in packs._neecha_layers_text(state, "zh")
|
||
assert packs._neecha_layers_text(state, "zh").startswith("原始尊贵:落陷,不变。")
|