定向测试和 200 张英文扫描通过。一张虚构盘中英合计约 20 秒。土星和 KP 结果段仍按修复单让步。 Co-Authored-By: Grok (agent loop)
89 lines
3.9 KiB
Python
89 lines
3.9 KiB
Python
"""Annual expansion adds rows without replacing the year lord, Muntha, Mudda source, Sahams or Tajika."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from types import SimpleNamespace
|
|
|
|
from scripts.annual_native.annual_expansion import attach_annual_expansion
|
|
|
|
_PLANETS = ("Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn", "Rahu", "Ketu")
|
|
|
|
|
|
def _pack() -> dict:
|
|
return {
|
|
"year_lord": {"year_lord": "Mars", "marker": "keep"},
|
|
"muntha": {"muntha_sign": "Leo"},
|
|
"mudda_dasha": {"periods": [{"lord": "Jupiter", "start": "2026-01-01", "end": "2026-03-01"}]},
|
|
"sahams": {"vivah_saham": {"longitude": 12.5, "name": "Vivah"}},
|
|
"tajika_yogas": {"status": "partial_verified", "items": ["keep-me"]},
|
|
"solar_return": {"jd_ut": 2460676.5, "dt_local": "2025-01-15 08:00:00"},
|
|
"annual_houses": {
|
|
"ascendant_longitude": 15.0,
|
|
"planet_longitudes": {name: float((index + 1) * 17) for index, name in enumerate(_PLANETS)},
|
|
},
|
|
}
|
|
|
|
|
|
def _payload() -> dict:
|
|
return {
|
|
"target_year": 2026,
|
|
"birth": {"latitude": 39.9, "longitude": 116.4, "utc_offset": "+08:00"},
|
|
"settings": {"ayanamsa": "lahiri", "node_mode": "mean", "dasha_year_days": 365.25},
|
|
}
|
|
|
|
|
|
def _args() -> SimpleNamespace:
|
|
return SimpleNamespace(year=1985, month=6, day=15, hour=8, minute=30, lat=39.9, lon=116.4, tz=8.0, second=0)
|
|
|
|
|
|
def _quiet(monkeypatch) -> None:
|
|
monkeypatch.setattr(
|
|
"scripts.annual_native.annual_expansion.build_monthly_charts",
|
|
lambda **_kwargs: {"rows": [{"month_index": index, "status": "partial_verified"} for index in range(1, 13)]},
|
|
)
|
|
monkeypatch.setattr(
|
|
"scripts.annual_native.annual_expansion.build_tithi_pravesh",
|
|
lambda _payload: {"status": "partial_verified", "natal_phase_degrees": 12.0, "rows": [{"local_datetime": "2026-02-01 00:00:00"}]},
|
|
)
|
|
|
|
|
|
def test_later_year_expansion_keeps_the_original_annual_facts(monkeypatch) -> None:
|
|
_quiet(monkeypatch)
|
|
pack = _pack()
|
|
attach_annual_expansion(pack, _payload(), _args(), include_overview=False)
|
|
assert pack["year_lord"] == {"year_lord": "Mars", "marker": "keep"}
|
|
assert pack["muntha"]["muntha_sign"] == "Leo"
|
|
assert pack["mudda_dasha"]["periods"][0]["lord"] == "Jupiter"
|
|
assert pack["sahams"]["vivah_saham"]["longitude"] == 12.5
|
|
assert pack["tajika_yogas"]["items"] == ["keep-me"]
|
|
assert len(pack["monthly_chart_pack"]["rows"]) == 12
|
|
assert pack["monthly_chart_pack"]["status"] == "partial_verified"
|
|
assert pack["normalized_tables"]["mudda_rows"][0]["lord"] == "Jupiter"
|
|
assert pack["normalized_tables"]["patyayini_rows"]
|
|
assert pack["tithi_pravesh_years"][0]["target_year"] == 2026
|
|
assert "annual_chart_series_pack" not in pack
|
|
|
|
|
|
def test_primary_year_leaves_mudda_rows_for_the_language_projector(monkeypatch) -> None:
|
|
_quiet(monkeypatch)
|
|
monkeypatch.setattr(
|
|
"scripts.annual_native.annual_expansion._eight_year",
|
|
lambda *_args, **_kwargs: {"birth_place_eight_year_overview": {"status": "partial_verified", "rows": []}},
|
|
)
|
|
# 原值:assert "lifetime_annual_chart_pages" not in pack
|
|
# 新值:报告年写入 72 行生命周期年返
|
|
# 原因:产品 10-23 拍板 K3,这一项不再让步
|
|
monkeypatch.setattr(
|
|
"scripts.annual_native.annual_expansion._lifetime",
|
|
lambda *_args, **_kwargs: {"status": "partial_verified", "pages": [{"rows": [{"completed_age": age} for age in range(72)]}]},
|
|
)
|
|
pack = _pack()
|
|
attach_annual_expansion(pack, _payload(), _args(), include_overview=True)
|
|
assert "mudda_rows" not in pack["normalized_tables"]
|
|
assert pack["normalized_tables"]["patyayini_rows"]
|
|
assert "birth_place_eight_year_overview" in pack["annual_chart_series_pack"]
|
|
rows = pack["lifetime_annual_chart_pages"]["pages"][0]["rows"]
|
|
assert len(rows) == 72
|
|
assert rows[0]["completed_age"] == 0
|
|
assert rows[-1]["completed_age"] == 71
|