Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017eEAG8HD3mm8gsKXgk8uU8
59 lines
2.4 KiB
Python
59 lines
2.4 KiB
Python
"""The chart page's dignity and varga-meaning tables must be the engine's.
|
|
|
|
`frontend/src/lib/vedic-chart-tables.json` is read by the chart-page mapper so
|
|
the divisional tables can show 入旺 / 自宫 / 落陷 without a second hand-written
|
|
rule set. This test pins it to the constants `jyotish_engine._get_dignity_level`
|
|
uses and to `divisional_charts_extended.VargaType`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / "scripts"))
|
|
|
|
import divisional_charts_extended # noqa: E402
|
|
import jyotish_engine # noqa: E402
|
|
|
|
TABLES = json.loads((ROOT / "frontend/src/lib/vedic-chart-tables.json").read_text(encoding="utf-8"))
|
|
PLANETS = ["Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn", "Rahu", "Ketu"]
|
|
|
|
|
|
def _table_dignity(planet: str, sign: str) -> str | None:
|
|
"""Same precedence as `vargaDignity` in frontend/src/lib/chart-view-varga.ts."""
|
|
if TABLES["exaltation"].get(planet) == sign:
|
|
return "EXALTED"
|
|
if TABLES["signLords"].get(sign) == planet or TABLES["nodeOwnSign"].get(planet) == sign:
|
|
return "OWN_SIGN"
|
|
if TABLES["debilitation"].get(planet) == sign:
|
|
return "DEBILITATED"
|
|
return None
|
|
|
|
|
|
def test_tables_equal_engine_constants() -> None:
|
|
assert TABLES["signLords"] == jyotish_engine.SIGN_LORDS
|
|
assert TABLES["exaltation"] == jyotish_engine.EXALTATION
|
|
assert TABLES["debilitation"] == jyotish_engine.DEBILITATION
|
|
|
|
|
|
def test_every_planet_sign_pair_matches_engine_dignity_level() -> None:
|
|
for planet in PLANETS:
|
|
for sign in jyotish_engine.SIGN_LORDS:
|
|
# No degree and no chart context: the varga table shows the sign
|
|
# dignity only (no moolatrikona band, no neecha bhanga, no friendship).
|
|
engine = jyotish_engine._get_dignity_level(planet, sign)
|
|
expected = engine if engine in {"EXALTED", "OWN_SIGN", "DEBILITATED"} else None
|
|
if engine == "NEECHA_BHANGA":
|
|
expected = "DEBILITATED"
|
|
assert _table_dignity(planet, sign) == expected, (planet, sign, engine)
|
|
|
|
|
|
def test_varga_meanings_equal_engine_varga_types() -> None:
|
|
engine = {str(v.division): v.meaning for v in divisional_charts_extended.VargaType if v.division <= 60}
|
|
assert TABLES["vargaMeaning"] == engine
|
|
for division in ("40", "45", "60"):
|
|
assert division in TABLES["vargaMeaning"]
|