Files
Jyotisha/tests/test_shadbala_minimum_first.py
T
Jesse_ChenandClaude Opus 5.5 5fdf2f7498 feat(shadbala): BPHS minimum check first, bands labelled as the site's (T3, BUG-1208)
Astrologer ruling 甲13. New scripts/shadbala_display.py (display only; shadbala.py is
frozen and unchanged): chart.shadbala now carries min_required, meets_minimum,
minimum_check (达到/未达到 BPHS 最低要求), level_source=site_band and level
'<band>(网站分档)'; report Shadbala table gains 'BPHS minimum' and 'Site band'
columns (zh/en); evidence snapshot ranking and health narrative say the minimum
check first and mark the band as the site's.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
2026-10-03 12:30:19 +08:00

54 lines
3.1 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:
assert minimum_fields(6.0, 6.5, "略弱") == {
"min_required": 6.5, "meets_minimum": False, "minimum_check": "未达到 BPHS 最低要求",
"level_source": "site_band", "level": "略弱(网站分档)"}
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, "level_source": "site_band"}
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_then_site_band() -> None:
packet = _packet(CASES["day"])
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, "reader_main")
header = next(line for line in markdown.splitlines() if line.startswith("| Planet | Sthana |"))
assert header.rstrip(" |").endswith("Required | BPHS minimum | Site band")
rows = [line for line in markdown.splitlines()[markdown.splitlines().index(header) + 2:][:7]]
assert len(rows) == 7 and all(check in row and band in row for row in rows), 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():
assert set(row) == {"rupas", "min_required", "meets_minimum", "minimum_check", "level_source", "level"}, 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["level_source"] == "site_band" and row["level"].endswith("(网站分档)")
assert row["minimum_check"] in ("达到 BPHS 最低要求", "未达到 BPHS 最低要求")