Files
Jyotisha/tests/test_shastihayani_dasha.py
T
Jesse_ChenandCursor 04ad3325d5
Independent Staging Quality Gate / validate (push) Successful in 11m26s
Independent Staging Quality Gate / publish (push) Successful in 13m24s
fix(relationship): freeze marriage event classes and add conditional dashas (BUG-608)
Venus/Jupiter/Moon periods no longer collapse into one marriage-opportunity line. Full reading reports the ten BPHS conditional dasha families; Skill 6.9.16.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-09 16:04:52 +08:00

124 lines
4.9 KiB
Python

"""Source-bounded regression tests for Shastihayani MD."""
from __future__ import annotations
import json
from datetime import datetime
from pathlib import Path
from scripts.shastihayani_dasha import (
calculate_shastihayani_dasha,
resolve_shastihayani_28_position,
shastihayani_applicability,
)
from scripts.source_bounded_child_periods import PYJHORA_PARENT_SEEDED_EQUAL_SPLIT_PROFILE
ROOT = Path(__file__).resolve().parents[1]
def test_shastihayani_requires_sun_in_lagna_sign() -> None:
assert shastihayani_applicability(ascendant_longitude=250.0, sun_longitude=251.0)["applicable"]
assert not shastihayani_applicability(ascendant_longitude=250.0, sun_longitude=281.0)["applicable"]
def test_shastihayani_blocks_without_explicit_28_nakshatra_group_position() -> None:
result = calculate_shastihayani_dasha({
"birth_datetime": "1902-12-23T07:23:00",
"ascendant_longitude": 250.0,
"sun_longitude": 251.0,
})
assert result["execution_status"] == "blocked"
assert "shastihayani_group_index" in result["reason"]
def test_shastihayani_resolves_abhijit_modified_28_star_position_from_moon_longitude() -> None:
uttara_ashadha = resolve_shastihayani_28_position(270.0)
abhijit = resolve_shastihayani_28_position(278.0)
shravana = resolve_shastihayani_28_position(281.0)
assert uttara_ashadha["nakshatra"] == "Uttara Ashadha"
assert uttara_ashadha["shastihayani_group_index"] == 5
assert uttara_ashadha["nakshatra_index_within_group"] == 3
assert abhijit["nakshatra"] == "Abhijit"
assert abhijit["shastihayani_group_index"] == 6
assert abhijit["nakshatra_index_within_group"] == 0
assert shravana["nakshatra"] == "Shravana"
assert shravana["shastihayani_group_index"] == 6
assert shravana["nakshatra_index_within_group"] == 1
def test_shastihayani_can_derive_required_28_star_inputs_from_moon_longitude() -> None:
result = calculate_shastihayani_dasha({
"birth_datetime": "1902-12-23T07:23:00",
"ascendant_longitude": 250.0,
"sun_longitude": 251.0,
"moon_longitude": 278.0,
})
assert result["execution_status"] == "executed"
assert result["starting_lord"] == "Saturn"
assert result["shastihayani_group_index"] == 6
assert result["nakshatra_index_within_group"] == 0
assert result["major"][0]["lord"] == "Saturn"
def test_shastihayani_expands_ad_pd_only_with_explicit_child_profile() -> None:
result = calculate_shastihayani_dasha({
"birth_datetime": "1902-12-23T07:23:00",
"ascendant_longitude": 250.0,
"sun_longitude": 251.0,
"moon_longitude": 278.0,
"child_period_profile": PYJHORA_PARENT_SEEDED_EQUAL_SPLIT_PROFILE,
})
assert result["execution_status"] == "executed"
assert result["period_depth_status"] == "mahadasha_antardasha_pratyantardasha_executed_pyjhora_observed_profile"
assert result["child_period_profile"] == PYJHORA_PARENT_SEEDED_EQUAL_SPLIT_PROFILE
assert len(result["major"][0]["antardasha"]) == 8
assert len(result["antardasha"]) == 64
assert len(result["pratyantardasha"]) == 512
assert result["major"][0]["antardasha"][0]["lord"] == "Saturn"
assert result["major"][0]["antardasha"][0]["pratyantardasha"][0]["lord"] == "Saturn"
def test_shastihayani_pl9_standard_table_profile_emits_rows_when_classically_inapplicable() -> None:
result = calculate_shastihayani_dasha({
"birth_datetime": "2001-03-04T10:38:00",
"ascendant_longitude": 310.0,
"sun_longitude": 260.0,
"moon_longitude": 249.0,
"child_period_profile": PYJHORA_PARENT_SEEDED_EQUAL_SPLIT_PROFILE,
"standard_table_profile": "pl9_reports_all_dasha_tables_v1",
})
assert result["execution_status"] == "executed"
assert result["applicable"] is True
assert result["classical_applicability"]["applicable"] is False
assert result["standard_table_profile"] == "pl9_reports_all_dasha_tables_v1"
assert result["period_depth_status"] == "mahadasha_antardasha_pratyantardasha_executed_pyjhora_observed_profile"
assert result["major"]
assert result["antardasha"]
assert result["pratyantardasha"]
def test_shastihayani_replays_charan_singh_moon_balance_pattern() -> None:
result = calculate_shastihayani_dasha({
"birth_datetime": datetime(1902, 12, 23, 7, 23),
"ascendant_longitude": 250.0,
"sun_longitude": 251.0,
"shastihayani_group_index": 3,
"nakshatra_index_within_group": 2,
"nakshatra_fraction_elapsed": 757 / 800,
})
assert result["execution_status"] == "executed"
assert result["starting_lord"] == "Moon"
assert result["major"][0]["lord"] == "Moon"
assert result["major"][0]["years"] > 1.5
assert result["major"][0]["years"] < 1.6
assert result["period_depth_status"] == "mahadasha_executed_ad_pd_blocked_pending_row_level_replay"
assert "antardasha" not in result["major"][0]