Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXp2U3BH1SxwAGyhhbe1
57 lines
2.4 KiB
Python
57 lines
2.4 KiB
Python
"""BUG-2222 (upstream yinduzhanxing b6754475): Rajju / Musala / Nala — all seven visible planets, nodes excluded."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / "scripts"))
|
|
|
|
from yoga_engine import SIGNS, YogaEngine # noqa: E402
|
|
|
|
SEVEN = ["Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn"]
|
|
|
|
|
|
def run(rule_id, signs):
|
|
engine = YogaEngine(str(ROOT / "references" / "yoga_rules.json"))
|
|
engine.rules = [r for r in engine.rules if r["id"] == rule_id]
|
|
assert len(engine.rules) == 1
|
|
positions = {p: {"sign": s, "house": SIGNS.index(s) + 1} for p, s in signs.items()}
|
|
rows = engine.detect(positions, "Aries", context={"chart_type": "D1"})
|
|
# BUG-2299: detect keeps her blocked row for a rule that could not be evaluated; the rule's own rows are the others.
|
|
return [r for r in rows if r["rule_id"] == rule_id and r.get("display_status") != "blocked"], engine.last_evaluation_failures
|
|
|
|
|
|
@pytest.mark.parametrize("rule,signs", [
|
|
("bvr_rajju_yoga", ["Aries", "Cancer", "Libra", "Capricorn"]),
|
|
("bvr_musala_yoga", ["Taurus", "Leo", "Scorpio", "Aquarius"]),
|
|
("bvr_nala_yoga", ["Gemini", "Virgo", "Sagittarius", "Pisces"]),
|
|
])
|
|
def test_source_conditions_include_all_seven_and_exclude_nodes(rule, signs):
|
|
chart = {p: signs[i % 4] for i, p in enumerate(SEVEN)}
|
|
chart.update(Rahu="Aries" if "Aries" not in signs else "Taurus", Ketu="Libra")
|
|
(row,), failures = run(rule, chart)
|
|
assert failures == []
|
|
assert set(row["planets"]) == set(SEVEN)
|
|
assert row["formation_evidence"]["positions"] == {p: chart[p] for p in SEVEN}
|
|
wrong = next(s for s in SIGNS if s not in signs)
|
|
for p in SEVEN:
|
|
assert run(rule, {**chart, p: wrong}) == ([], [])
|
|
missing = dict(chart)
|
|
del missing[p]
|
|
rows, (failure,) = run(rule, missing)
|
|
assert rows == []
|
|
assert failure["condition_status"] == "incomplete_conditions"
|
|
assert failure["missing_inputs"] == [f"{p}.sign"]
|
|
rows, (failure,) = run(rule, {})
|
|
assert rows == [] and failure["condition_status"] == "incomplete_conditions"
|
|
|
|
|
|
def test_retired_heuristics_and_duplicate_cannot_run():
|
|
engine = YogaEngine(str(ROOT / "references" / "yoga_rules.json"))
|
|
ids = {r["id"] for r in engine.rules}
|
|
assert not ids & {"asraya_yoga", "asraya_partial", "kalatra_dosha_mars_7"}
|
|
assert "kalatra_dosha_mars_1_4_7_8_12" in ids
|