Files
Jyotisha/tests/test_upstream_r40_sync.py
T
ClaudeandClaude Opus 5.5 5d64f71b81 fix: astrologer round-5 rulings 2/3/4/5/10/13 (BUG-1746..1752)
- Functional default = PVR Table 30 (functional_profile=pvr_table_30); the former
  product table is bphs_exception_profile, scored only when named (rectification
  names it, scores unchanged). profile_divergence shows both roles side by side;
  movable-lagna Moon by the table's paksha note; dual-lordship note; prior rulings
  BUG-1570/1590/#166 Q4 checked against Table 30.
- Shadbala: six open items labelled parameter_sensitive; every option combination
  computed; only planets whose pass/fail flips get minimum_check=parameter_sensitive.
- Vimshottari AD/PD rows carry parent_period_start / visible_period_start; the
  consult card cuts the balance MD from its full parent and clips at birth.
- KP DBA: full first parent, clipped at birth (no balance rescale).
- Mudda: balance fields + balance_method (angle default, time comparison apart),
  nominal_year_days, her crossing wording; Harsha combined blocked reason lists items.
- D30 _meta describes the unequal parts (as her r40).
- Golden recaptured with TTL=0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
2026-11-08 11:57:22 +08:00

76 lines
4.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""交接 8c775cd0(r40)代码同步回归。
她的改动与本仓的对应关系:
- scripts/report_source_translation.py(两条整句译法)→ port 到
scripts/pl9_full_data_export._sanitize_pl9_ai_density_markdown_en;
- scripts/yoga_engine.py(诊断行保留 category)→ port 到 _not_implemented_row
与 evaluation_failure_row;
- scripts/jyotish_engine.py(适用 Yoga 表排除 not_implemented / evaluation_error)
→ equivalent:本仓诊断行另存于 unimplemented_rules / evaluation_failures,
从不进入 detected_yogas,见下方最后一条测试。
"""
import re
import sys
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts"))
@pytest.mark.parametrize("house", [2, 7, 8])
def test_public_fixture_condition_phrases_translate_variable_house_numbers(house):
# 移植自她的 tests/test_delivery_module_restoration.py
from pl9_full_data_export import _sanitize_pl9_ai_density_markdown_en
for source in (f"火星在第{house}宫(从月亮的2/12宫)",
f"有Pitra Dosha迹象:Sun({house}宫)与Rahu({house + 1}宫)合相/相邻"):
result = _sanitize_pl9_ai_density_markdown_en(source).split("\n", 2)[-1]
assert not re.search(r"[一-鿿]", result)
assert re.findall(r"\d+", result) == re.findall(r"\d+", source)
assert "from Moon" in _sanitize_pl9_ai_density_markdown_en(f"火星在第{house}宫(从月亮的2/12宫)")
assert "Pitra Dosha indication: " in _sanitize_pl9_ai_density_markdown_en("有Pitra Dosha迹象:Sun(1宫)")
def test_diagnostic_rows_keep_rule_category():
# 移植自她的 tests/test_r37_followup_repairs.py 新增断言
from yoga_engine import _not_implemented_row, evaluation_failure_row
assert _not_implemented_row({"id": "x"}, ["c"])["category"] == "unclassified_rule"
assert _not_implemented_row({"id": "x", "category": "raja"}, ["c"])["category"] == "raja"
assert evaluation_failure_row({"id": "x"}, ValueError("boom"))["category"] == "unclassified_rule"
def test_diagnostic_rows_never_enter_detected_yogas():
from yoga_engine import YogaEngine
src = (ROOT / "scripts" / "yoga_engine.py").read_text(encoding="utf-8")
# 诊断行只追加到 unimplemented / failures,然后 continue,不会进入 results
assert "unimplemented.append(_not_implemented_row(rule, exc.conditions))\n continue" in src
assert "failures.append(evaluation_failure_row(rule, exc))\n continue" in src
assert YogaEngine
def test_pvr_table30_is_a_separate_named_profile_and_virgo_matches_product():
# 占星师 2026-11-07 Q7: Virgo Sun / Saturn are functional neutrals in PVR Table 30.
from functional_benefics import derive_functional_benefic_malefic, pvr_table30_roles, PVR_TABLE30_PROFILE
# 原值:derive_functional_benefic_malefic("Virgo") 是产品表,profile_is_not == PVR。新值:产品表须明确选中
# bphs_exception_profile;默认档是 PVR 表 30。原因:占星师 2026-11-08 第五轮裁定 3
product = derive_functional_benefic_malefic("Virgo", functional_profile="bphs_exception_profile")
pvr = pvr_table30_roles("Virgo")
assert {"Sun", "Saturn"} <= set(product["functional_neutrals"])
assert pvr["functional_neutrals"] == ["Saturn", "Sun"]
assert product["profile"] != PVR_TABLE30_PROFILE and product["profile_is_not"] == PVR_TABLE30_PROFILE
assert derive_functional_benefic_malefic("Virgo")["profile"] == PVR_TABLE30_PROFILE
differing = []
for sign in ("Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius",
"Capricorn", "Aquarius", "Pisces"):
ours, ref = derive_functional_benefic_malefic(sign, functional_profile="bphs_exception_profile"), pvr_table30_roles(sign)
for role in ("functional_benefics", "functional_neutrals", "functional_malefics"):
for planet in set(ref[role]) - set(ours[role]):
differing.append((sign, planet))
assert sorted(differing) == sorted([("Aries", "Mars"), ("Gemini", "Mercury"), ("Cancer", "Saturn"),
("Libra", "Venus"), ("Scorpio", "Sun"), ("Pisces", "Jupiter")])