Files
Jyotisha/tests/test_expression_paths_wiring_2296.py
T

48 lines
2.6 KiB
Python

"""BUG-2296(占星师 2026-11-23 信息密度交接 §3,负责人 2026-11-24「接着做」):上游 yoga_expression_paths 原样移植,
本站只在 report_render/expression_paths_wiring.py 里转换输入形状。只用公开盘与虚构数据。"""
from __future__ import annotations
import hashlib
import subprocess
from scripts.report_render import expression_paths_wiring as wiring
from scripts.report_render import reading_facts
from tests.public_chart_reports import public_chart_reports
def test_the_module_is_upstream_verbatim() -> None:
upstream = subprocess.run(["git", "-C", "/workspace/yinduzhanxing", "show", "58f37ee5b:scripts/yoga_expression_paths.py"],
capture_output=True, check=False)
if upstream.returncode != 0: # the astrologer's checkout is not on every machine
return
with open("scripts/yoga_expression_paths.py", "rb") as handle:
assert hashlib.sha256(handle.read()).hexdigest() == hashlib.sha256(upstream.stdout).hexdigest()
def test_functional_blocked_planets_reach_her_status_field() -> None:
module = {"functional_profile": "pvr_table30_v1", "blocked_planets": ["Moon"], "functional_benefics": ["Moon"]}
adapted = wiring._functional(module)
assert adapted["profile"] == "pvr_table30_v1" and adapted["planet_status"] == {"Moon": "blocked"}
from scripts.yoga_expression_paths import _functional_role
assert _functional_role(adapted, "Moon")["role"] == "not assessed"
def test_the_pd_is_passed_only_when_usable() -> None:
dasha = {"current_dasha": {"lord": "Saturn"}, "timeline": [{"lord": "Saturn", "is_current": True, "antardasha_timeline": [
{"lord": "Venus", "is_current": True, "pratyantar_dasha_timeline": [{"lord": "Jupiter", "is_current": True}]}]}]}
used = wiring._dasha(dasha, True)["current_dasha"]["antardasha"]
assert used["lord"] == "Venus" and used["pratyantar_dasha_timeline"] == [{"lord": "Jupiter", "is_current": True}]
unused = wiring._dasha(dasha, False)["current_dasha"]["antardasha"]
assert "pratyantar_dasha_timeline" not in unused
def test_public_report_carries_the_paths_in_both_editions_and_the_writer_gets_them() -> None:
packet, chinese, english = public_chart_reports("steve_jobs_1955_aa")
assert "### 瑜伽作用路径:条件、支持与阶段" in chinese
assert "### Yoga Expression: Conditions, Support and Period Context" in english
paths = wiring.stored_expression_paths(packet)
assert paths and paths["rows"] and paths["life_history_used"] is False
rows = reading_facts._expression_paths(packet)
assert rows and all(row["kind"] not in ("argala", "kp_parallel") for row in rows)