Files
Jyotisha/tests/test_full_reading_conditional_dashas.py
T
ClaudeandClaude Opus 5.5 9cfc823e2e
Independent Staging Quality Gate / validate-frontend (push) Successful in 5m9s
Independent Staging Quality Gate / validate-python (push) Successful in 5m49s
Independent Staging Quality Gate / publish (push) Successful in 2m50s
fix(dasha): astrologer second ruling — Drig uses Narayana years, Ashtottari decided by the Rahu gate, Sthira variants kept apart (BUG-1676, BUG-1677, BUG-1678)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXoyeZrYn6ryNcSe5Y2Y
2026-11-07 14:05:06 +08:00

128 lines
4.5 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.
"""Conditional dasha families in full reading and the time-system table."""
from __future__ import annotations
from pathlib import Path
from scripts.jyotish_engine import cmd_full_reading, render_pl9_markdown, _native_dasha_master_families
from scripts.professional_report_reference import _export_args
from tests.test_report_longform_parity import _producer_packet
ROOT = Path(__file__).resolve().parents[1]
BASELINE = (ROOT / "tests/golden/upstream_sync2/pl9_time_system_table.baseline.md").read_text(encoding="utf-8")
EINSTEIN = {
"year": 1879,
"month": 3,
"day": 14,
"hour": 11,
"minute": 30,
"second": 0,
"lat": 48.4,
"lon": 9.98,
"tz": 0.89,
"ayanamsa": "raman",
"node_mode": "mean",
}
CONDITIONAL_KEYS = (
"tribhagi_dasha",
"tribhagi_40_dasha",
"shodashottari_dasha",
"dwadashottari_dasha",
"dwisaptatisama_dasha",
"shattrimshatsama_dasha",
"panchottari_dasha",
"satabdika_dasha",
"chaturshitisama_dasha",
"shastihayani_dasha",
)
NEW_TABLE_LABELS = (
"Tribhagi",
"Tribhagi 40",
"Shodashottari",
"Dwadashottari",
"Dwisaptatisama",
"Shastihayani",
"Shattrimshatsama",
"Panchottari",
"Satabdika",
"Chaturshitisama",
)
def _table_data_rows(markdown: str) -> list[str]:
lines = markdown.splitlines()
start = next(i for i, line in enumerate(lines) if line.strip() == "#### 时间系统证据状态")
rows = []
for line in lines[start + 3 :]:
if not line.startswith("|"):
break
if line.startswith("|------"):
continue
if line.startswith("| 系统 |"):
continue
rows.append(line)
return rows
def test_einstein_full_reading_exposes_ten_conditional_dasha_modules() -> None:
report = cmd_full_reading(_export_args(EINSTEIN))
modules = report.get("modules") if isinstance(report.get("modules"), dict) else {}
for key in CONDITIONAL_KEYS:
payload = modules.get(key)
assert isinstance(payload, dict), key
has_periods = isinstance(payload.get("periods"), list) or isinstance(payload.get("major"), list)
status = str(payload.get("execution_status") or payload.get("status") or "")
assert has_periods or status in {"not_applicable", "blocked"} or payload.get("error"), key
markdown = render_pl9_markdown(_producer_packet({
"timing_and_predictive_systems": {
"dasha": modules.get("dasha"),
"narayana_dasha": modules.get("narayana_dasha"),
"yogini_dasha": modules.get("yogini_dasha"),
"ashtottari_dasha": modules.get("ashtottari_dasha"),
"kalachakra_dasha": modules.get("kalachakra_dasha"),
**{key: modules.get(key) for key in CONDITIONAL_KEYS},
"dasha_master_pack": {
"schema": "dasha_master_report_pack_v1",
"families": _native_dasha_master_families(modules),
},
"annual_tajika_pack": {"year_lord": {"status": "partial_verified"}},
},
}))
rows = _table_data_rows(markdown)
original = [
line for line in BASELINE.splitlines()
if line.startswith("| ")
and not line.startswith("| 系统 |")
and "| Year Lord |" not in line
]
# 原值: rows[:5] == original(Ashtottari 行为 executed / 本地候选规则)
# 新值: 其余四行不变;Ashtottari 行按 BPHS 罗睺条件判为 not_applicable 并写本盘情况
# 原因: BUG-1676,占星师 2026-11-07 裁定 Ashtottari 生产口径(这张公开盘罗睺在上升主星起算第 11 位)
assert [row for row in rows[:5] if not row.startswith("| Ashtottari |")] == [
row for row in original[:5] if not row.startswith("| Ashtottari |")]
ashtottari_row = next(row for row in rows[:5] if row.startswith("| Ashtottari |"))
assert ashtottari_row.startswith("| Ashtottari | not_applicable | — | 不满足 BPHS 条件:")
for label in NEW_TABLE_LABELS:
assert any(f"| {label} |" in line for line in rows)
assert any("| Year Lord |" in line for line in rows)
assert len(rows) >= 15
def test_calc_dasa_convergence_call_is_unchanged() -> None:
text = (ROOT / "scripts/jyotish_engine.py").read_text(encoding="utf-8")
needle = """ convergence = _calc_dasa_convergence(
dasha_data,
chara_dasha_data,
yogini_data,
planet_lons,
asc_idx,
ashtottari_result=ashtottari_data,
kalachakra_result=kalachakra_data,
)"""
assert needle in text