Files
Jyotisha/tests/test_api_chart_ascendant_nakshatra.py
T
jesse-uxGrok (agent loop)Cursor
454951de27 fix(chart): keep the ascendant nakshatra the page already renders
The chart API rebuilt the ascendant without nakshatra, lord, and pada, so those cells stayed blank. Cache schema is now 7. Centered column headers line up with their cells, and the current dasha card keeps its tint without the left accent.

pytest 34 passed. tsc 0 errors. lint 0 errors and 123 existing warnings.

Co-Authored-By: Grok (agent loop)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-15 09:46:37 +08:00

57 lines
1.8 KiB
Python

"""The chart API must keep the ascendant nakshatra the engine already computed."""
from __future__ import annotations
import sys
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1]
SCRIPTS = ROOT / "scripts"
TESTS = ROOT / "tests"
for path in (SCRIPTS, TESTS):
if str(path) not in sys.path:
sys.path.insert(0, str(path))
import jyotish_api_server # noqa: E402
from test_api_server_security import _handler # noqa: E402
BEIJING = {
"year": 1990,
"month": 6,
"day": 15,
"hour": 12,
"minute": 0,
"second": 0,
"lat": 39.9042,
"lon": 116.4074,
"tz": 8,
"ayanamsa": "raman",
"node_mode": "mean",
"transit_date": "2026-10-15",
"skip_vedastro_main_entry_overview": True,
}
def test_api_chart_keeps_ascendant_nakshatra_from_the_engine(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("JYOTISH_API_CHART_CACHE_TTL_SECONDS", "0")
monkeypatch.setenv("VEDASTRO_ENABLE_NETWORK", "0")
monkeypatch.setattr(
jyotish_api_server,
"_attach_vedastro_main_entry_overview",
lambda result, _birth: result,
)
engine = jyotish_api_server._load_local_module("jyotish_engine")
result = _handler()._compute_chart_sync(BEIJING)
lon = result["ascendant"]["lon"]
expected = engine._nakshatra_fields(lon)
for packet in (result["ascendant"], result["modules"]["chart"]["ascendant"]):
assert packet["nakshatra"] == expected["nakshatra"]
assert packet["nakshatra_pada"] == expected["nakshatra_pada"]
assert packet["nakshatra_lord"] == expected["nakshatra_lord"]
assert result["ascendant"]["nakshatra"] == "Uttara Phalguni"
assert result["ascendant"]["nakshatra_pada"] == 1
assert result["ascendant"]["nakshatra_lord"] == "Sun"