"""Source-bounded regression tests for the local Shodashottari producer.""" from __future__ import annotations import json from datetime import datetime from pathlib import Path from scripts.shodashottari_dasha import calculate_shodashottari_dasha, shodashottari_applicability from scripts.source_bounded_child_periods import PYJHORA_PARENT_SEEDED_EQUAL_SPLIT_PROFILE ROOT = Path(__file__).resolve().parents[1] def test_shodashottari_accepts_the_two_classical_hora_paksha_gates() -> None: assert shodashottari_applicability(ascendant_longitude=5.0, sun_longitude=0.0, moon_longitude=90.0)["applicable"] assert shodashottari_applicability(ascendant_longitude=20.0, sun_longitude=0.0, moon_longitude=270.0)["applicable"] def test_shodashottari_rejects_the_crossed_hora_paksha_cases() -> None: result = shodashottari_applicability(ascendant_longitude=20.0, sun_longitude=0.0, moon_longitude=90.0) assert result["applicable"] is False assert result["hora_lord"] == "Moon" assert result["paksha"] == "shukla" def test_shodashottari_builds_birth_balance_without_inventing_ad_pd_boundaries() -> None: result = calculate_shodashottari_dasha({ "birth_datetime": datetime(2000, 1, 1, 12, 0), "ascendant_longitude": 5.0, "sun_longitude": 0.0, "moon_longitude": 95.0, "dasha_year_days": 365.25636, }) assert result["execution_status"] == "executed" assert result["confidence_status"] == "parameter_sensitive" assert result["applicable"] is True assert result["starting_lord"] == "Sun" # Pushya is the Shodashottari seed. assert result["total_cycle"] == 116 assert result["major"][0]["planet"] == "Sun" assert result["major"][0]["start_date"] == "2000-01-01T12:00:00" assert result["major"][0]["years"] < 11.0 assert result["period_depth_status"] == "mahadasha_executed_ad_pd_blocked_pending_row_level_replay" assert "antardasha" not in result["major"][0] def test_shodashottari_keeps_non_applicable_result_non_executed() -> None: result = calculate_shodashottari_dasha({ "birth_datetime": "2000-01-01T12:00:00", "ascendant_longitude": 20.0, "sun_longitude": 0.0, "moon_longitude": 95.0, }) assert result["execution_status"] == "not_applicable" assert result["major"] == [] def test_shodashottari_standard_table_profile_preserves_unmet_gate_but_emits_rows() -> None: result = calculate_shodashottari_dasha({ "birth_datetime": "2000-01-01T12:00:00", "ascendant_longitude": 20.0, "sun_longitude": 0.0, "moon_longitude": 95.0, "standard_table_profile": "pl9_reports_all_dasha_tables_v1", }) assert result["execution_status"] == "executed" assert result["classical_applicable"] is False assert result["standard_table_profile"] == "pl9_reports_all_dasha_tables_v1" assert len(result["major"]) == 8 def test_shodashottari_can_emit_pyjhora_observed_child_profile_when_explicit() -> None: result = calculate_shodashottari_dasha({ "birth_datetime": datetime(2000, 1, 1, 12, 0), "ascendant_longitude": 5.0, "sun_longitude": 0.0, "moon_longitude": 95.0, "child_period_profile": PYJHORA_PARENT_SEEDED_EQUAL_SPLIT_PROFILE, }) first_md = result["major"][0] first_ad = first_md["antardasha"][0] first_pd = first_ad["pratyantardasha"][0] assert result["period_depth_status"] == "mahadasha_antardasha_pratyantardasha_executed_pyjhora_observed_profile" assert len(result["antardasha"]) == 64 assert len(result["pratyantardasha"]) == 512 assert first_ad["lord"] == first_md["lord"] assert first_pd["lord"] == first_ad["lord"] assert first_md["antardasha"][-1]["end_date"] == first_md["end_date"]