"""BUG-1548: the chart page's Shadbala is the same precise calculation as readings. The chart API called calc_shadbala without a context and so took the simplified fallback (no sunrise, house midpoints or declination), while cmd_shadbala, the full reading and reports pass build_shadbala_context. On Steve Jobs' chart the two disagreed by up to four Rupa and on the strongest planet. """ from __future__ import annotations import sys from pathlib import Path from types import SimpleNamespace import pytest ROOT = Path(__file__).resolve().parents[1] for path in (ROOT / "scripts", ROOT / "tests"): if str(path) not in sys.path: sys.path.insert(0, str(path)) import jyotish_engine # noqa: E402 from test_api_server_security import _handler # noqa: E402 # Public Rodden AA chart (Astro-Databank): Steve Jobs, San Francisco. BODY = { "year": 1955, "month": 2, "day": 24, "hour": 19, "minute": 15, "second": 0, "lat": 37.7749, "lon": -122.4194, "tz": -8, "ayanamsa": "raman", "node_mode": "mean", "transit_date": "2026-09-27", "skip_vedastro_main_entry_overview": True, } def test_chart_page_shadbala_equals_the_precise_engine_calculation(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setenv("JYOTISH_API_CHART_CACHE_TTL_SECONDS", "0") monkeypatch.setenv("VEDASTRO_ENABLE_NETWORK", "0") chart = _handler()._compute_chart(dict(BODY)) page = chart["shadbala"] args = SimpleNamespace( year=1955, month=2, day=24, hour=19, minute=15, second=0, lat=37.7749, lon=-122.4194, tz=-8.0, ayanamsa="raman", node_mode="mean", ) engine = jyotish_engine.cmd_shadbala(args) assert set(page) == set(engine["planets"]) for planet, row in engine["planets"].items(): assert page[planet]["rupas"] == pytest.approx(round(row["total_rupas"], 2), abs=0.011), planet