Files
Jyotisha/tests/test_thematic_dasha_info_source.py
T
jesse-uxandGrok (agent loop) c7350bcafb 把星盘接口的计算和 HTTP 拆成两个类,离线入口不再伪造请求对象。
方法体未改。定向测试 383 通过;1 条校正回归在基线上同样失败,断言未改。快速门和全量 pytest 未跑。

Co-Authored-By: Grok (agent loop)
2026-10-16 10:24:42 +08:00

78 lines
2.5 KiB
Python

"""Current MD/AD for thematic reports come from dasha_sub_periods, not birth MD."""
from __future__ import annotations
from scripts.jyotish_api_server import JyotishComputeService
def _handler() -> JyotishComputeService:
return JyotishComputeService()
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