"""Current MD/AD for thematic reports come from dasha_sub_periods, not birth MD.""" from __future__ import annotations from scripts.jyotish_api_server import JyotishAPIHandler def _handler() -> JyotishAPIHandler: return JyotishAPIHandler.__new__(JyotishAPIHandler) def test_prefers_dasha_sub_periods_current_over_birth_md() -> None: info = _handler()._thematic_dasha_info( { "dasha": {"current_md": "Rahu"}, "modules": { "dasha_sub_periods": { "current": { "mahadasha": {"lord": "Saturn"}, "antardasha": {"lord": "Jupiter"}, } } }, }, {"current_md": "Rahu", "periods": []}, ) assert info["maha_dasha"] == "Saturn" assert info["antar_dasha"] == "Jupiter" def test_falls_back_to_vimshottari_analysis_when_sub_periods_missing() -> None: info = _handler()._thematic_dasha_info( {"dasha": {"current_md": "Rahu"}}, { "vimshottari_analysis": { "current": { "mahadasha": {"lord": "Venus"}, "antardasha": {"lord": "Moon"}, } } }, ) assert info["maha_dasha"] == "Venus" assert info["antar_dasha"] == "Moon" def test_omits_maha_dasha_when_neither_source_has_current_lords() -> None: info = _handler()._thematic_dasha_info({"dasha": {"current_md": "Rahu"}}, {"periods": []}) assert "maha_dasha" not in info assert "antar_dasha" not in info def test_timeline_fills_current_antardasha_from_sub_periods() -> None: timeline = _handler()._normalize_thematic_dasha_timeline( { "periods": [ {"lord": "Saturn", "start": "2009-05-25", "end": "2028-05-25"}, ], "modules": { "dasha_sub_periods": { "current": { "mahadasha": {"lord": "Saturn"}, "antardasha": {"lord": "Jupiter"}, } } }, } ) assert timeline[0]["mahadasha"] == "Saturn" assert timeline[0]["antardasha"] == "Jupiter" def test_source_tests_are_on_the_quick_quality_gate() -> None: from scripts.run_quality_gate import CORE_PYTEST_TARGETS assert "tests/test_thematic_dasha_info_source.py" in CORE_PYTEST_TARGETS assert "tests/test_report_orchestrator_marriage_timing.py" in CORE_PYTEST_TARGETS