Files
Jyotisha/tests/test_partial_yoga_reader_2421.py
ClaudeandClaude Opus 5.5 644c4f70d0
Independent Staging Quality Gate / validate-python (push) Successful in 8m19s
Independent Staging Quality Gate / validate-frontend (push) Successful in 6m44s
Independent Staging Quality Gate / publish (push) Successful in 4m13s
fix(report): describe a partly met yoga from what is met in personal, annual and synastry writing; dismissals go back for a rewrite (BUG-2421)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXp3RzgZVEpT1PXxkwHj
2026-11-26 17:46:47 +08:00

64 lines
3.7 KiB
Python

"""BUG-2421 (占星师原则,负责人 2026-11-26 转发;问答一侧是 BUG-2420): reports describe a not-fully-formed yoga from
what IS satisfied and the related placements, and never dismiss it."""
from __future__ import annotations
from pathlib import Path
from scripts.marriage_match_service.synastry_full_reader_gate import EN_INTERNAL_WORDING, ZH_INTERNAL_WORDING
from scripts.report_render import reading_facts
from scripts.report_render.yoga_status_words import YOGA_NOTICE_EN, YOGA_NOTICE_ZH
from tests.public_chart_reports import public_chart_reports
ROOT = Path(__file__).resolve().parents[1]
DISMISSALS_ZH = ("条件待核", "无法分析", "强弱另评", "没有据此加强")
def test_participant_placements_come_from_the_engine_row() -> None:
row = {"condition_evidence": {"participants": {
"Moon": {"sign": "Pisces", "house": 7}, "Mars": {"sign": "Aries", "house": 8}, "Ketu": {"sign": "Gemini"},
"Lagna": "not a dict", "Pluto": {"sign": "Aries", "house": 1}}}}
assert reading_facts._yoga_placements_zh(row) == "月亮在双鱼座第 7 宫;火星在白羊座第 8 宫;计都在双子座"
assert reading_facts._yoga_placements_zh(None) == ""
assert reading_facts._yoga_placements_zh({"condition_evidence": {}}) == ""
def test_public_chart_facts_give_each_partial_yoga_its_met_conditions_and_placements() -> None:
packet, _chinese, _english = public_chart_reports("steve_jobs_1955_aa")
yogas = reading_facts._yogas(packet)
partial = [row for row in yogas if row["state"] != "formed_under_source"]
assert partial, "the public chart has yogas that are not fully formed"
by_id = {row.get("evidence_id"): row for row in partial}
sunapha = by_id["ev:yoga:bvr_002_sunapha_precise@D1"]
assert sunapha["state"] == "candidate"
assert sunapha["conditions"] == "火星Mars在月亮的第2宫"
assert sunapha["placements_zh"] == "月亮在双鱼座第 7 宫;火星在白羊座第 8 宫"
# Most partial rows carry at least one of the two; none carries a dismissal as text for the writer.
assert sum(1 for row in partial if row.get("conditions") or row.get("placements_zh")) >= len(partial) - 2
for row in partial:
for value in (row.get("conditions"), row.get("placements_zh"), row.get("state_text")):
assert not any(word in (value or "") for word in DISMISSALS_ZH), (row.get("evidence_id"), value)
def test_writer_rule_describes_partial_yogas_instead_of_dismissing_them() -> None:
contract = (ROOT / "references" / "product_runtime_contract.md").read_text(encoding="utf-8")
block = contract.split("<!-- product-block:report-reading -->", 1)[1].split("<!-- /product-block:report-reading -->", 1)[0]
assert "盘里有某某格局的迹象,这一点目前还不能明确判断" not in block
assert "各节正文不拿它下判断" not in block
for needle in ("placements_zh", "已经满足的部分", "支持和压力一起写", "不等于这方面的能力或事情没有", "不把可能写成确定"):
assert needle in block
def test_yoga_table_notice_no_longer_dismisses_the_rows() -> None:
_packet, chinese, english = public_chart_reports("steve_jobs_1955_aa")
assert "才能把某个候选当作起作用" not in chinese
assert "before treating a candidate as operative" not in english
assert YOGA_NOTICE_ZH in chinese and YOGA_NOTICE_EN in english
assert "不等于格局已经形成" in YOGA_NOTICE_ZH and "does not make the yoga formed" in YOGA_NOTICE_EN
def test_synastry_gate_asks_for_a_rewrite_on_dismissals() -> None:
for word in DISMISSALS_ZH:
assert word in ZH_INTERNAL_WORDING
assert "strength assessed separately" in EN_INTERNAL_WORDING