Aspect table in degrees with special aspect names, Ayana angle no longer called declination, annual planets read from planet_longitudes, both neecha bhanga rows kept, PD lord counted in house activation, sub-periods name their parent period, Saham formulas with real operators, D30 source input, Pushkara, Graha Pada, A10, Argala undecided, Moon chart degree, Lagna nakshatra, gana, Shadbala units, place label in the English edition. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXp2Vp62Ur3C7yRWQdSq
67 lines
4.2 KiB
Python
67 lines
4.2 KiB
Python
"""Shadbala: BPHS minimum first, the band labelled as the site's (BUG-1208).
|
||
|
||
Astrologer rulings 2026-10-03 甲13 (TASK-astrologer-rulings-batch1-20261003 T3).
|
||
`shadbala.py` is unchanged (frozen rectification identity); display fields come
|
||
from `shadbala_display`. Fictional chart for the report render.
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import copy
|
||
|
||
from scripts.pl9_reader_export import _pl9_export_markdown_for_edition
|
||
from scripts.shadbala import MIN_REQUIRED
|
||
from scripts.shadbala_display import band_text, minimum_fields, row_fields
|
||
from tests.test_report_english_edition import CASES, _packet
|
||
|
||
|
||
def test_minimum_fields() -> None:
|
||
# 原值: 另带 "level_source": "site_band"、"level": "略弱(网站分档)"
|
||
# 新值: 只有最低线、是否达到、达到与否的那句话
|
||
# 原因: BUG-1961,占星师 2026-11-17 Q2:150/125/100/75/50 % 分档没有具名规则和来源,冻结前不显示
|
||
assert minimum_fields(6.0, 6.5, "略弱") == {
|
||
"min_required": 6.5, "meets_minimum": False, "minimum_check": "未达到 BPHS 最低要求"}
|
||
assert minimum_fields(6.5, 6.5, "充足")["meets_minimum"] is True
|
||
assert minimum_fields(None, 6.5, None) == {"min_required": 6.5, "meets_minimum": None, "minimum_check": None}
|
||
assert row_fields({"total_rupas": 5.1, "min_required": MIN_REQUIRED["Mars"], "strength_level": "充足"})["meets_minimum"] is True
|
||
assert band_text("充足", "en") == "adequate (site band)"
|
||
|
||
|
||
def test_report_table_shows_minimum_check_and_no_site_band() -> None:
|
||
packet = _packet(CASES["day"])
|
||
# 原值: 表末列 Site band,每行带「(网站分档)」/ "(site band)"
|
||
# 新值: 表末列是 BPHS minimum,整份报告不出现分档字样
|
||
# 原因: BUG-1961
|
||
for language, check, band in (("zh", "BPHS 最低要求", "(网站分档)"), ("en", "BPHS minimum", "(site band)")):
|
||
edition = copy.deepcopy(packet)
|
||
edition["report_language"] = language
|
||
markdown = _pl9_export_markdown_for_edition(edition, "full_data")
|
||
# 原值:表头以 | Planet | Sthana | 开头
|
||
# 新值:中文以 | 行星 | Sthana | 开头;英文仍是 | Planet | Sthana |
|
||
# 原因:完整数据版中文清理把 Planet 写成「行星」。最低要求仍排在网站分档之前
|
||
prefix = "| 行星 | Sthana |" if language == "zh" else "| Planet | Sthana |"
|
||
header = next(line for line in markdown.splitlines() if line.startswith(prefix))
|
||
# 原值: 表头以 "Required | BPHS minimum" 结尾
|
||
# 新值: 中文以 "所需(Rupa) | BPHS minimum" 结尾,英文以 "Required (Rupa) | BPHS minimum" 结尾
|
||
# 原因: BUG-2065 合计是 Virupa、所需是 Rupa,表头各写单位
|
||
assert header.rstrip(" |").endswith(("所需(Rupa) | BPHS minimum" if language == "zh" else "Required (Rupa) | BPHS minimum"))
|
||
rows = [line for line in markdown.splitlines()[markdown.splitlines().index(header) + 2:][:7]]
|
||
assert len(rows) == 7 and all(check in row for row in rows), language
|
||
assert band not in markdown and "Site band" not in markdown and "网站分档" not in markdown, language
|
||
|
||
|
||
def test_consultation_chart_summary_carries_the_fields() -> None:
|
||
"""`chart.shadbala` (copied onto the consultation card) from a live chart."""
|
||
from scripts.capture_report_blocked_repairs_golden import _handler
|
||
|
||
case = CASES["day"]
|
||
chart = _handler()._compute_chart({**{key: case[key] for key in ("year", "month", "day", "hour", "minute", "second", "lat", "lon", "tz", "ayanamsa", "node_mode")},
|
||
"skip_vedastro_main_entry_overview": True})
|
||
assert set(chart["shadbala"]) == {"Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn"}
|
||
for planet, row in chart["shadbala"].items():
|
||
# 原值: 另有 level_source、level 两个键;新值: 没有;原因: BUG-1961
|
||
assert set(row) == {"rupas", "min_required", "meets_minimum", "minimum_check"}, planet
|
||
assert row["min_required"] == MIN_REQUIRED[planet]
|
||
assert row["meets_minimum"] == (row["rupas"] >= MIN_REQUIRED[planet]) or abs(row["rupas"] - MIN_REQUIRED[planet]) < 0.01
|
||
assert row["minimum_check"] in ("达到 BPHS 最低要求", "未达到 BPHS 最低要求")
|