Owner 2026-11-21: after BUG-2115 the full-data report still printed source lines and book references (Goel 出处 line, the PVR 2014 article in the conditional-dasha note, PVR / Light on Life / BPHS verse in the calculation notes, Tithi lord table source, rashi-dasha 出处 lines, Narayana p.43 label and p.50 / Table 13 direction notes, functional profile source row, Ashtakavarga book calibration). Method names stay; the book, page, chapter and ruling round go. Engine labels for the consultation card are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXp2U3BH1SxwAGyhhbe1
466 lines
25 KiB
Python
466 lines
25 KiB
Python
"""Book-shaped rashi dasha rows. These tests do not import PyJHora."""
|
||
|
||
from __future__ import annotations
|
||
|
||
import ast
|
||
import json
|
||
from datetime import date
|
||
from pathlib import Path
|
||
|
||
from scripts.goel_short_strength import dignity_units, graha_strengths, rashi_strengths
|
||
from scripts.rashi_dashas_native import (
|
||
calculate_rashi_dashas,
|
||
drig_aspect_sequence,
|
||
navamsha_sign,
|
||
navamsha_years,
|
||
niryaana_shoola_applicability,
|
||
niryaana_shoola_mahadashas,
|
||
select_niryaana_shoola_start_sign,
|
||
)
|
||
from scripts.rashi_dasha_report import render_rashi_dasha_chapter
|
||
|
||
ROOT = Path(__file__).resolve().parents[1]
|
||
FIXTURE = ROOT / "tests" / "fixtures" / "rashi_dasha_pyjhora_20261008.json"
|
||
GOEL_LONS = {
|
||
"Sun": 0 * 30 + 20.18,
|
||
"Moon": 7 * 30 + 20.15,
|
||
"Mars": 7 * 30 + 23.02,
|
||
"Mercury": 1 * 30 + 11.12,
|
||
"Jupiter": 5 * 30 + 3.13,
|
||
"Venus": 11 * 30 + 17.28,
|
||
"Saturn": 0 * 30 + 7.07,
|
||
}
|
||
CAPRICORN_STRONGER = {
|
||
"Sun": 9 * 30 + 1,
|
||
"Moon": 9 * 30 + 2,
|
||
"Mars": 9 * 30 + 3,
|
||
"Mercury": 9 * 30 + 4,
|
||
"Jupiter": 9 * 30 + 5,
|
||
"Venus": 9 * 30 + 6,
|
||
"Saturn": 6 * 30 + 15,
|
||
"Rahu": 15.0,
|
||
"Ketu": 195.0,
|
||
}
|
||
|
||
|
||
def test_goel_short_method_matches_the_printed_totals_and_direct_sthira() -> None:
|
||
graha = graha_strengths(GOEL_LONS)
|
||
assert [graha[name]["total"] for name in ("Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn")] == [
|
||
150, 120, 180, 130, 70, 150, 50,
|
||
]
|
||
rashi = rashi_strengths(GOEL_LONS, graha)
|
||
assert [rashi[index]["total"] for index in range(12)] == [
|
||
280, 260, 250, 260, 250, 260, 230, 300, 250, 130, 150, 260,
|
||
]
|
||
packet = calculate_rashi_dashas(date(2001, 1, 1), 5 * 30 + 1.55, GOEL_LONS)
|
||
sthira = packet["sthira"]
|
||
# 原值: profile_id == "goel_rao_short_brahma_method_v1"
|
||
# 新值: 短法只在完整方法无法运行时作退路,并带 _fallback 与原因
|
||
# 原因: BUG-1677,占星师 2026-11-07 裁定 Sthira 默认用 Goel 完整方法;本夹具没有罗睺 / 计都,完整方法不能运行
|
||
assert sthira["profile_id"] == "goel_rao_short_brahma_method_v1_fallback"
|
||
assert sthira["full_method_reason"] == "full_method_needs_ascendant_and_nodes"
|
||
assert sthira["brahma_planet"] == "Mars"
|
||
assert [row["sign_index"] for row in sthira["periods"]] == list(range(7, 12)) + list(range(0, 7))
|
||
assert [row["years"] for row in sthira["periods"]] == [8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7]
|
||
aquarius = sthira["periods"][3]
|
||
assert aquarius["sign"] == "Aquarius"
|
||
assert aquarius["start"] == "2025-01-01"
|
||
assert [row["sign"] for row in aquarius["antardasha"][:2]] == ["Aquarius", "Pisces"]
|
||
assert aquarius["antardasha"][0]["end"] == "2025-09-01"
|
||
assert "pratyantar" not in aquarius
|
||
|
||
|
||
def test_same_goel_chart_niryaana_uses_pvr_not_the_shoola_rule() -> None:
|
||
# 原值:首运 Virgo,十二段都是 9 年,并有从 Virgo 起的子运。
|
||
# 新值:profile pvr_niryaana_shoola_v1,首运 Aries、顺行,年数 7/8/9,没有子运。
|
||
# 原因:产品 2026-10-18 推翻 BUG-1283 所选的 goel_nirayana_shoola_v1。那套和 Shoola 是同一张表。
|
||
packet = calculate_rashi_dashas(date(2001, 1, 1), 5 * 30 + 1.55, GOEL_LONS)
|
||
niryaana = packet["niryaana_shoola"]
|
||
shoola = packet["shoola"]
|
||
assert niryaana["profile_id"] == "pvr_niryaana_shoola_v1"
|
||
assert niryaana["status"] == "listed"
|
||
assert niryaana["direction"] == "forward"
|
||
assert niryaana["periods"][0]["sign"] == "Aries"
|
||
assert [row["years"] for row in niryaana["periods"][:3]] == [7, 8, 9]
|
||
# 原值:没有子运("antardasha" 不在首段)。
|
||
# 新值:子运从大运星座起顺排十二宫、均分(上游导出口径)。
|
||
# 原因:产品负责人 2026-11-06 决定按上游导出补 Niryaana Shoola 子运。
|
||
assert [child["sign"] for child in niryaana["periods"][0]["antardasha"]][:2] == ["Aries", "Taurus"]
|
||
assert (
|
||
niryaana["periods"][0]["sign"] != shoola["periods"][0]["sign"]
|
||
or [row["years"] for row in niryaana["periods"]] != [row["years"] for row in shoola["periods"]]
|
||
)
|
||
|
||
|
||
def test_drig_aspect_order_for_a_cancer_lagna_and_narayana_style_years() -> None:
|
||
assert drig_aspect_sequence(3) == [11, 8, 5, 2, 0, 4, 7, 10, 1, 9, 6, 3]
|
||
packet = calculate_rashi_dashas(date(2001, 1, 1), 3 * 30 + 1.0, GOEL_LONS)
|
||
drig = packet["drig"]
|
||
assert drig["profile_id"] == "drig_rath_aspect_sequence_v1"
|
||
assert [row["sign_index"] for row in drig["periods"]] == drig_aspect_sequence(3)
|
||
assert all(isinstance(row["years"], int) and 0 <= row["years"] <= 12 for row in drig["periods"])
|
||
|
||
|
||
def test_shoola_from_the_stronger_seventh_puts_aries_at_year_27() -> None:
|
||
packet = calculate_rashi_dashas(date(2001, 1, 1), 3 * 30 + 1.0, CAPRICORN_STRONGER)
|
||
shoola = packet["shoola"]
|
||
assert shoola["profile_id"] == "shoola_forward_md_direct_ad_v1"
|
||
assert [row["sign"] for row in shoola["periods"][:4]] == ["Capricorn", "Aquarius", "Pisces", "Aries"]
|
||
assert shoola["periods"][3]["start"] == "2028-01-01"
|
||
assert shoola["periods"][3]["years"] == 9
|
||
assert shoola["periods"][0]["antardasha"][0]["sign"] == "Capricorn"
|
||
|
||
|
||
def test_navamsha_method_1_starts_from_the_seventh_when_d9_lagna_is_even() -> None:
|
||
longitude = 3 * 30 + 26.7
|
||
assert navamsha_sign(longitude) == 11
|
||
assert navamsha_years(0, 0) == 12
|
||
assert navamsha_years(0, 1) == 2
|
||
assert navamsha_years(1, 0) == 2
|
||
packet = calculate_rashi_dashas(date(2001, 1, 1), longitude, GOEL_LONS)
|
||
navamsha = packet["navamsha"]
|
||
assert navamsha["profile_id"] == "goel_method_1_v1"
|
||
assert navamsha["d9_lagna_index"] == 11
|
||
assert navamsha["periods"][0]["sign"] == "Virgo"
|
||
assert navamsha["periods"][0]["antardasha"][0]["sign"] == "Virgo"
|
||
assert "pratyantar" not in navamsha["periods"][0]
|
||
|
||
|
||
def test_chara_keeps_the_existing_kn_rao_order_and_a_zero_year_row() -> None:
|
||
longitudes = {name: 10.0 for name in ("Sun", "Moon", "Mars", "Mercury", "Venus", "Saturn", "Rahu")}
|
||
longitudes["Jupiter"] = 9 * 30 + 5.0
|
||
longitudes["Ketu"] = 190.0
|
||
packet = calculate_rashi_dashas(date(2001, 1, 1), 10.0, longitudes)
|
||
chara = packet["chara"]
|
||
assert chara["profile_id"] == "kn_rao"
|
||
assert [row["sign_index"] for row in chara["periods"]] == list(range(12))
|
||
sagittarius = chara["periods"][8]
|
||
assert sagittarius["sign"] == "Sagittarius"
|
||
assert sagittarius["years"] == 0
|
||
assert sagittarius["start"] == sagittarius["end"]
|
||
assert chara["periods"][0]["antardasha"][0]["sign"] == "Taurus"
|
||
assert chara["periods"][0]["antardasha"][-1]["sign"] == "Aries"
|
||
|
||
|
||
def test_lagna_kendradi_is_listed_with_the_upstream_profile() -> None:
|
||
# 原值:status omitted,periods 为空(没有选定的安全默认算法)。
|
||
# 新值:按上游 kendradi_narayana_duration_candidate_v1 列 12 段大运,不列子运。
|
||
# 原因:产品负责人 2026-11-06 决定按上游导出补 Lagna Kendradi。
|
||
packet = calculate_rashi_dashas(date(2001, 1, 1), 10.0, GOEL_LONS)
|
||
section = packet["lagna_kendradi"]
|
||
assert section["status"] == "listed"
|
||
assert section["profile_id"] == "kendradi_narayana_duration_candidate_v1"
|
||
assert len(section["periods"]) == 12
|
||
assert section["periods"][0]["sign"] == "Aries"
|
||
|
||
|
||
def test_mercury_in_virgo_uses_longitude_bands() -> None:
|
||
assert dignity_units("Mercury", 5, 10.0) == 70
|
||
assert dignity_units("Mercury", 5, 16.0) == 60
|
||
assert dignity_units("Mercury", 5, 22.0) == 50
|
||
|
||
|
||
def test_report_modules_do_not_call_the_old_shoola_or_niryaana_helpers() -> None:
|
||
for name in ("rashi_dashas_native.py", "rashi_dasha_report.py", "goel_short_strength.py"):
|
||
source = (ROOT / "scripts" / name).read_text(encoding="utf-8")
|
||
tree = ast.parse(source)
|
||
imported = []
|
||
for node in ast.walk(tree):
|
||
if isinstance(node, ast.ImportFrom) and node.module:
|
||
imported.append(node.module)
|
||
elif isinstance(node, ast.Import):
|
||
imported.extend(alias.name for alias in node.names)
|
||
assert "niryaana_shoola_dasha" not in imported
|
||
assert "extended_dashas" not in imported
|
||
assert all(not item.split(".")[0] == "jhora" for item in imported)
|
||
|
||
|
||
def test_niryaana_shoola_starts_from_the_stronger_second_or_eighth() -> None:
|
||
taurus = select_niryaana_shoola_start_sign(ascendant_longitude=0.0, planet_longitudes={"Mars": 31.0})
|
||
scorpio = select_niryaana_shoola_start_sign(ascendant_longitude=0.0, planet_longitudes={"Mars": 211.0})
|
||
assert taurus["selected_sign"] == "Taurus"
|
||
assert scorpio["selected_sign"] == "Scorpio"
|
||
taurus_rows = niryaana_shoola_mahadashas(date(2000, 1, 1), taurus["selected_sign_idx"])
|
||
scorpio_rows = niryaana_shoola_mahadashas(date(2000, 1, 1), scorpio["selected_sign_idx"])
|
||
assert [row["sign"] for row in taurus_rows[:2]] == ["Taurus", "Aries"]
|
||
assert [row["sign"] for row in scorpio_rows[:2]] == ["Scorpio", "Libra"]
|
||
|
||
|
||
def test_niryaana_shoola_odd_signs_go_forward_and_even_signs_go_backward() -> None:
|
||
even_seed = niryaana_shoola_applicability(ascendant_longitude=0.0, second_strength=2.0, eighth_strength=1.0)
|
||
odd_seed = select_niryaana_shoola_start_sign(ascendant_longitude=45.0, planet_longitudes={"Mars": 61.0})
|
||
assert even_seed["starting_sign"] == "Taurus"
|
||
assert even_seed["direction"] == "reverse"
|
||
assert odd_seed["selected_sign"] == "Gemini"
|
||
odd_rows = niryaana_shoola_mahadashas(date(2000, 1, 1), odd_seed["selected_sign_idx"])
|
||
assert [row["sign"] for row in odd_rows[:2]] == ["Gemini", "Cancer"]
|
||
assert [row["years"] for row in odd_rows[:3]] == [9, 7, 8]
|
||
|
||
|
||
def test_niryaana_shoola_given_strengths_match_the_upstream_mahadasha_golden() -> None:
|
||
# Golden copied from upstream 9f08b57b tests/test_niryaana_shoola_dasha.py
|
||
# test_niryaana_shoola_uses_modality_years_and_parity_direction.
|
||
picked = niryaana_shoola_applicability(
|
||
ascendant_longitude=15.0, second_strength=2.0, eighth_strength=1.0,
|
||
)
|
||
rows = niryaana_shoola_mahadashas(date(2000, 1, 1), picked["starting_sign_index"])
|
||
assert [row["sign"] for row in rows[:3]] == ["Taurus", "Aries", "Pisces"]
|
||
assert [row["years"] for row in rows[:3]] == [8, 7, 9]
|
||
assert [row["sign"] for row in rows] == [
|
||
"Taurus", "Aries", "Pisces", "Aquarius", "Capricorn", "Sagittarius",
|
||
"Scorpio", "Libra", "Virgo", "Leo", "Cancer", "Gemini",
|
||
]
|
||
assert [row["years"] for row in rows] == [8, 7, 9, 8, 7, 9, 8, 7, 9, 8, 7, 9]
|
||
assert sum(row["years"] for row in rows) == 96
|
||
assert all("antardasha" not in row for row in rows)
|
||
|
||
|
||
def test_two_public_charts_match_the_upstream_start_signs() -> None:
|
||
# Claude 10-18, upstream 9f08b57b: one chart starts in Sagittarius, one in Aquarius.
|
||
# These two public charts are the pair. Sequences are the PVR mahadashas from that start.
|
||
expected = {
|
||
"brad_pitt": (
|
||
"Sagittarius",
|
||
["Sagittarius", "Capricorn", "Aquarius", "Pisces", "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio"],
|
||
[9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8],
|
||
),
|
||
"jolie": (
|
||
"Aquarius",
|
||
["Aquarius", "Pisces", "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn"],
|
||
[8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7],
|
||
),
|
||
}
|
||
sources = {
|
||
"brad_pitt": ROOT / "tests/indastro_cases.json",
|
||
"jolie": ROOT / "tests/celebrity_cases.json",
|
||
}
|
||
from scripts.jyotish_engine import compute_chart_data
|
||
|
||
for case_id, (start, signs, years) in expected.items():
|
||
rows = json.loads(sources[case_id].read_text(encoding="utf-8"))
|
||
birth = next(row for row in rows if row["id"] == case_id)
|
||
chart, _asc, _jd, _ayanamsa = compute_chart_data(
|
||
birth["year"], birth["month"], birth["day"], birth["hour"], birth["minute"],
|
||
birth["lat"], birth["lon"], birth["tz"], second=birth.get("second") or 0,
|
||
ayanamsa_name="lahiri",
|
||
)
|
||
longitudes = {
|
||
name: float(row["degree_raw"])
|
||
for name, row in chart["planets"].items()
|
||
if isinstance(row, dict) and "degree_raw" in row
|
||
}
|
||
section = calculate_rashi_dashas(
|
||
chart["birth_info"]["date"], float(chart["ascendant"]["degree_raw"]), longitudes,
|
||
)["niryaana_shoola"]
|
||
assert section["status"] == "listed"
|
||
assert section["direction"] == "forward"
|
||
assert [row["sign"] for row in section["periods"]] == signs
|
||
assert section["periods"][0]["sign"] == start
|
||
assert [row["years"] for row in section["periods"]] == years
|
||
# 原值:所有大运都没有子运。新值:每段大运 12 个子运(上游口径)。原因:2026-11-06 产品决定。
|
||
assert all(len(row["antardasha"]) == 12 for row in section["periods"])
|
||
|
||
|
||
def test_niryaana_shoola_tie_stays_off_the_table() -> None:
|
||
tied = {name: 3 * 30 + 10.0 for name in ("Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn")}
|
||
section = calculate_rashi_dashas(date(2001, 1, 1), 0.5, tied)["niryaana_shoola"]
|
||
assert section["status"] == "omitted"
|
||
assert section["periods"] == []
|
||
assert "本轮不上表" in section["reason_zh"]
|
||
assert "二宫与八宫力量相同" in section["reason_zh"]
|
||
|
||
|
||
def test_niryaana_shoola_counts_both_nodes_and_ignores_outer_planets() -> None:
|
||
# Same placements as upstream 258e08e3.
|
||
occupancy = select_niryaana_shoola_start_sign(
|
||
ascendant_longitude=0.0,
|
||
planet_longitudes={"Rahu": 31.0, "Ketu": 211.0, "Pluto": 31.0},
|
||
)
|
||
aspects = select_niryaana_shoola_start_sign(
|
||
ascendant_longitude=0.0,
|
||
planet_longitudes={"Rahu": 1.0, "Ketu": 181.0},
|
||
)
|
||
assert occupancy["included_bodies"][-2:] == ["Rahu", "Ketu"]
|
||
assert occupancy["candidates"][1]["occupants"] == ["Rahu"]
|
||
assert occupancy["candidates"][7]["occupants"] == ["Ketu"]
|
||
assert "Pluto" not in occupancy["candidates"][1]["occupants"]
|
||
assert aspects["candidates"][1]["rasi_aspecting_planets"] == ["Ketu"]
|
||
assert aspects["candidates"][7]["rasi_aspecting_planets"] == ["Rahu"]
|
||
without_outer = select_niryaana_shoola_start_sign(ascendant_longitude=0.0, planet_longitudes={"Mars": 31.0})
|
||
with_outer = select_niryaana_shoola_start_sign(
|
||
ascendant_longitude=0.0, planet_longitudes={"Mars": 31.0, "Uranus": 211.0},
|
||
)
|
||
assert without_outer["selected_sign"] == with_outer["selected_sign"] == "Taurus"
|
||
assert "Uranus" not in with_outer["candidates"][7]["occupants"]
|
||
|
||
|
||
def test_pyjhora_fixture_diffs_stay_on_the_recorded_steps() -> None:
|
||
# 原值:niryaana_shoola 的 native 行与 Shoola 一样,从上升或第七宫起、每段 9 年,并带子运差异。
|
||
# 新值:同一键改为 PVR 主运的星座和年数;diff_steps 按新表相对 PyJHora 重记。
|
||
# 原因:产品 2026-10-18 改口径。PyJHora 对照行没有重跑,只改我们自己的期望。
|
||
# 原值:乔布斯 / 奥巴马 / 爱因斯坦三盘 native.chara 年数各有一段(水瓶或天蝎)与 PyJHora 不同,diff_steps 含 years。
|
||
# 新值:三盘 Chara 年数与 PyJHora 4.8.7 对照行逐段相同,diff_steps 只剩 subperiod。
|
||
# 原因:BUG-1566 天蝎 / 水瓶双主星按盘面判定(一主在本宫取另一主)。PyJHora 对照行未重跑。
|
||
# 原值:native.drig.years 按奇偶足数到星座主星(不计入旺落陷与双主择强)。
|
||
# 新值:native.drig.years 重冻为本站 Narayana(Rath)同一星座年数函数的结果;星座顺序与 diff_steps 不变。
|
||
# 原因:BUG-1678,占星师 2026-11-07 第二次裁定 Drig 年数与 Narayana 相同(PVR 21.2(5))。PyJHora 对照行未重跑;
|
||
# 新年数与 PyJHora 更接近(乔布斯前 12 段逐段相同),剩下的差别仍在已记录的 direction 一步。
|
||
payload = json.loads(FIXTURE.read_text(encoding="utf-8"))
|
||
assert payload["pyjhora_version"] == "4.8.7"
|
||
assert payload["generator_python_has_pyjhora"] is True
|
||
from scripts.jyotish_engine import compute_chart_data
|
||
|
||
for case_id, case in payload["cases"].items():
|
||
birth = case["birth_source"]
|
||
chart, _asc, _jd, _ayanamsa = compute_chart_data(
|
||
birth["year"], birth["month"], birth["day"], birth["hour"], birth["minute"],
|
||
birth["lat"], birth["lon"], birth["tz"], second=birth.get("second") or 0,
|
||
ayanamsa_name="lahiri", # the frame PyJHora was frozen in
|
||
)
|
||
assert chart is not None
|
||
longitudes = {
|
||
name: float(row["degree_raw"])
|
||
for name, row in chart["planets"].items()
|
||
if isinstance(row, dict) and "degree_raw" in row
|
||
}
|
||
native = calculate_rashi_dashas(chart["birth_info"]["date"], float(chart["ascendant"]["degree_raw"]), longitudes)
|
||
for key, expected in case["diff_steps"].items():
|
||
section = native[key]
|
||
recorded = case["native"][key]
|
||
if key == "lagna_kendradi":
|
||
# 原值:本仓 omitted。新值:按上游候选口径列出;与 PyJHora 的差别只能落在记录的几步里。
|
||
# 原因:2026-11-06 产品决定按上游导出补 Lagna Kendradi。
|
||
assert section["status"] == "listed"
|
||
assert expected == ["start_sign", "direction", "years", "subperiod"]
|
||
assert set(_diff_steps(section, case["pyjhora"][key])) <= set(expected)
|
||
continue
|
||
assert [row["sign_index"] for row in section["periods"]] == recorded["sign_indexes"]
|
||
assert [row["years"] for row in section["periods"]] == recorded["years"]
|
||
assert _diff_steps(section, case["pyjhora"][key]) == expected
|
||
|
||
|
||
def _succession(signs: list[int]) -> tuple[int, ...]:
|
||
return tuple((signs[index] - signs[index - 1]) % 12 for index in range(1, len(signs)))
|
||
|
||
|
||
def _diff_steps(section: dict, pyjhora: dict) -> list[str]:
|
||
our_signs = [row["sign_index"] for row in section["periods"]]
|
||
their_signs = pyjhora["sign_indexes"]
|
||
our_years = [row["years"] for row in section["periods"]]
|
||
their_years = pyjhora["years"]
|
||
steps = []
|
||
if not our_signs or not their_signs or our_signs[0] != their_signs[0]:
|
||
steps.append("start_sign")
|
||
if _succession(our_signs) != _succession(their_signs):
|
||
steps.append("direction")
|
||
if sorted(zip(our_signs, our_years)) != sorted(zip(their_signs, their_years)):
|
||
steps.append("years")
|
||
our_sub = [row["sign_index"] for row in (section["periods"][0].get("antardasha") or [])] if section["periods"] else []
|
||
their_sub = pyjhora.get("first_sub_sign_indexes") or []
|
||
if our_sub != their_sub:
|
||
steps.append("subperiod")
|
||
if our_signs == their_signs and our_years == their_years and section["periods"][1:2]:
|
||
if section["periods"][1]["start"] != pyjhora.get("second_start"):
|
||
steps.append("date_basis")
|
||
return steps
|
||
|
||
|
||
def test_jobs_chapter_names_the_method_and_lists_the_upstream_tables() -> None:
|
||
payload = json.loads(FIXTURE.read_text(encoding="utf-8"))
|
||
birth = payload["cases"]["steve_jobs_1955_aa"]["birth_source"]
|
||
from scripts.jyotish_engine import compute_chart_data
|
||
|
||
chart, _asc, _jd, _ayanamsa = compute_chart_data(
|
||
birth["year"], birth["month"], birth["day"], birth["hour"], birth["minute"],
|
||
birth["lat"], birth["lon"], birth["tz"], second=birth.get("second") or 0,
|
||
)
|
||
packet = {
|
||
"report_language": "zh",
|
||
"birth_info": {"date": chart["birth_info"]["date"], "name": "steve_jobs_1955_aa"},
|
||
"core_chart": {"ascendant": chart["ascendant"], "planets": chart["planets"]},
|
||
}
|
||
text = render_rashi_dasha_chapter(packet)
|
||
for title in ("Sthira", "Niryaana Shoola", "Drig", "Navamsha", "Shoola", "Chara"):
|
||
assert f"### {title}" in text
|
||
niryaana = text.split("### Niryaana Shoola", 1)[1].split("### ", 1)[0]
|
||
# 原值: assert "pvr_niryaana_shoola_v1" in niryaana(方法行印出 profile id)
|
||
# 新值: 方法行写方法名「PVR Niryaana Shoola」,不印 id
|
||
# 原因: BUG-2095 读者正文不出现内部代码
|
||
# 原值: 「本站选用的方法:PVR Niryaana Shoola,出处:…」
|
||
# 新值: 方法名后直接接「;未与外部软件逐一核对」,不写出处
|
||
# 原因: BUG-2129 负责人 2026-11-21:报告里不给读者出现书名、作者出处、页码和章节号
|
||
assert "本站选用的方法:PVR Niryaana Shoola;" in niryaana and "pvr_niryaana_shoola_v1" not in niryaana
|
||
assert "出处" not in text and "印页" not in text
|
||
# 原值:"子运规则未定,暂不列出。",子表表头 "| 序号 | 主运 | 子运 |"
|
||
# 新值:"小运规则未定,暂不列出。",子表表头 "| 序号 | 大运 | 小运 |"
|
||
# 原因:报告运期名称按占星师口径(issue #163 Q5):星座运第一层大运、第二层小运
|
||
# 原值:"小运规则未定,暂不列出。",没有小运表。
|
||
# 新值:写明原书没有单列小运规则、按上游口径只作对照,并列出小运表。
|
||
# 原因:产品负责人 2026-11-06 决定按上游导出补 Niryaana Shoola 子运。
|
||
# 原值: 「原书没有单列小运规则」 新值: 「没有单列的小运规则」
|
||
# 原因: BUG-2129 负责人 2026-11-21:报告里不给读者出现书名、作者出处、页码和章节号
|
||
assert "没有单列的小运规则" in niryaana and "只作对照" in niryaana and "原书" not in niryaana
|
||
assert "| 序号 | 大运 | 小运 |" in niryaana
|
||
assert "子运" not in text and "主运" not in text
|
||
assert "本站选用的方法:" in text
|
||
assert "未与外部软件逐一核对" in text
|
||
assert "K.N. Rao" in text
|
||
assert "不是 Narayana 表" in text
|
||
# 原值:Lagna Kendradi 写「本轮不上表」、没有表。新值:按上游候选口径列大运表并注明未经书例核对。
|
||
# 原因:2026-11-06 产品决定按上游导出补 Lagna Kendradi。
|
||
kendradi = text.split("### Lagna Kendradi", 1)[1]
|
||
assert "未经书例核对" in kendradi
|
||
assert "| 序号 | 星座 |" in kendradi
|
||
english = render_rashi_dasha_chapter({**packet, "report_language": "en"})
|
||
assert "Method used on this site:" in english
|
||
english_niryaana = english.split("### Niryaana Shoola Dasha", 1)[1].split("### ", 1)[0]
|
||
# 原值: assert "pvr_niryaana_shoola_v1" in english_niryaana
|
||
# 新值: the method line names "PVR Niryaana Shoola", no profile id
|
||
# 原因: BUG-2095 读者正文不出现内部代码
|
||
# 原值: "Method used on this site: PVR Niryaana Shoola, source: …"
|
||
# 新值: no source clause
|
||
# 原因: BUG-2129 负责人 2026-11-21:报告里不给读者出现书名、作者出处、页码和章节号
|
||
assert "Method used on this site: PVR Niryaana Shoola;" in english_niryaana and "pvr_niryaana_shoola_v1" not in english_niryaana
|
||
assert "source:" not in english and "printed page" not in english
|
||
assert "for comparison only" in english_niryaana
|
||
assert "Upstream candidate profile" in english
|
||
assert "not checked one-by-one against external software." in english
|
||
leaked = [char for char in english if "\u4e00" <= char <= "\u9fff"]
|
||
assert leaked == []
|
||
|
||
|
||
def test_full_data_report_appends_the_chapter_without_touching_a_chartless_packet() -> None:
|
||
from scripts.pl9_full_data_export import render_full_data_markdown
|
||
from tests.test_report_full_data_fix import _packet
|
||
|
||
chartless = render_full_data_markdown(_packet("zh"))
|
||
assert "Sthira Dasha" not in chartless
|
||
payload = json.loads(FIXTURE.read_text(encoding="utf-8"))
|
||
birth = payload["cases"]["steve_jobs_1955_aa"]["birth_source"]
|
||
from scripts.jyotish_engine import compute_chart_data
|
||
|
||
chart, _asc, _jd, _ayanamsa = compute_chart_data(
|
||
birth["year"], birth["month"], birth["day"], birth["hour"], birth["minute"],
|
||
birth["lat"], birth["lon"], birth["tz"], second=birth.get("second") or 0,
|
||
)
|
||
packet = _packet("zh")
|
||
packet["birth_info"]["date"] = chart["birth_info"]["date"]
|
||
packet["core_chart"] = {"ascendant": chart["ascendant"], "planets": chart["planets"]}
|
||
text = render_full_data_markdown(packet)
|
||
assert "星座大运" in text
|
||
assert "Sthira" in text
|
||
assert "本站选用的方法" in text
|
||
assert "Kendradi" in text
|
||
# 原值:「本轮不上表」且 Kendradi 后没有表。新值:列出 Kendradi 表。原因:2026-11-06 产品决定按上游导出。
|
||
kendradi = text.split("Kendradi", 1)[1]
|
||
assert "| 序号 | 星座 |" in kendradi
|
||
english_packet = _packet("en")
|
||
english_packet["birth_info"]["date"] = chart["birth_info"]["date"]
|
||
english_packet["core_chart"] = packet["core_chart"]
|
||
english = render_full_data_markdown(english_packet)
|
||
assert "Sthira" in english
|
||
assert "Method used on this site:" in english
|
||
# 原值:英文写 "This report does not include Lagna Kendradi"。新值:列出上游候选口径表。原因:2026-11-06 产品决定。
|
||
assert "Upstream candidate profile" in english
|
||
assert not any("\u4e00" <= char <= "\u9fff" for char in english)
|