fix(special-lagnas): compute birth-instant points via PyJHora (BUG-1265, upstream 1918ffaf)
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
"""BUG-1265: special lagnas come from the birth instant, not the identical local formulas."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from scripts.ayanamsa_utils import ACTIVE_AYANAMSA_NAME, apply_ayanamsa
|
||||
from scripts.special_lagnas import SpecialLagnasCalculator, bhava_house_rows
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def _jobs_birth():
|
||||
payload = json.loads((ROOT / "references" / "public_oracle_cases.json").read_text(encoding="utf-8"))
|
||||
birth = next(row["birth"] for row in payload["cases"] if row["id"] == "steve_jobs_1955_aa")
|
||||
return birth
|
||||
|
||||
|
||||
def test_public_jobs_hora_and_ghati_differ_and_match_birth_instant():
|
||||
birth = _jobs_birth()
|
||||
apply_ayanamsa("raman")
|
||||
before = ACTIVE_AYANAMSA_NAME
|
||||
moment = datetime(birth["year"], birth["month"], birth["day"], birth["hour"], birth["minute"], birth["second"])
|
||||
rows = SpecialLagnasCalculator().calculate_all_lagnas(
|
||||
0.0, 0.0, 0.0, moment, moment.replace(hour=6),
|
||||
lat=birth["lat"], lon=birth["lon"], tz_offset=birth["tz"], ayanamsa="lahiri",
|
||||
)
|
||||
expected = {
|
||||
"Bhava_Lagna": ("Leo", 17.12),
|
||||
"Hora_Lagna": ("Aquarius", 22.58),
|
||||
"Ghati_Lagna": ("Virgo", 8.94),
|
||||
}
|
||||
for key, (sign, degree) in expected.items():
|
||||
assert rows[key]["status"] == "computed"
|
||||
assert rows[key]["sign"] == sign
|
||||
assert rows[key]["sign_degree"] == pytest.approx(degree, abs=0.01)
|
||||
assert rows[key]["source"] == "pyjhora_drik"
|
||||
assert rows[key]["ayanamsa"] == "lahiri"
|
||||
assert rows["Hora_Lagna"]["sign"] != rows["Ghati_Lagna"]["sign"]
|
||||
for key in ("Sree_Lagna", "Indu_Lagna", "Pranapada_Lagna", "Varnada_Lagna"):
|
||||
assert rows[key]["status"] == "computed"
|
||||
assert rows[key]["sign"]
|
||||
assert ACTIVE_AYANAMSA_NAME == before
|
||||
|
||||
|
||||
def test_missing_coordinates_block_pyjhora_points_without_inventing_them():
|
||||
moment = datetime(1955, 2, 24, 19, 15, 0)
|
||||
rows = SpecialLagnasCalculator().calculate_all_lagnas(10.0, 20.0, 30.0, moment, moment.replace(hour=6))
|
||||
assert rows["Sree_Lagna"]["status"] == "blocked"
|
||||
assert rows["Sree_Lagna"]["reason"] == "birth_coordinates_or_timezone_missing"
|
||||
assert rows["Hora_Lagna"]["formula"]
|
||||
|
||||
|
||||
def test_missing_pyjhora_function_is_blocked(monkeypatch):
|
||||
import jhora.panchanga.drik as drik
|
||||
|
||||
monkeypatch.delattr(drik, "pranapada_lagna", raising=False)
|
||||
birth = _jobs_birth()
|
||||
moment = datetime(birth["year"], birth["month"], birth["day"], birth["hour"], birth["minute"], birth["second"])
|
||||
rows = SpecialLagnasCalculator().calculate_pyjhora_special_lagnas(
|
||||
moment, birth["lat"], birth["lon"], birth["tz"], 0.0, ayanamsa="lahiri",
|
||||
)
|
||||
assert rows["Pranapada_Lagna"]["status"] == "blocked"
|
||||
assert "pranapada_lagna" in rows["Pranapada_Lagna"]["reason"]
|
||||
|
||||
|
||||
def test_bhava_house_rows_drop_summary_rows():
|
||||
rows = bhava_house_rows({
|
||||
"houses": [
|
||||
{"house": 1, "sign": "Aries"},
|
||||
{"house": "total", "sign": "summary"},
|
||||
{"house": 12, "sign": "Pisces"},
|
||||
]
|
||||
})
|
||||
assert [row["house"] for row in rows] == [1, 12]
|
||||
Reference in New Issue
Block a user