Files
Jyotisha/tests/test_consultation_engine_field_bridge.py
T
Jesse_Chen 734d20590c
Independent Staging Quality Gate / validate (push) Failing after 31m48s
Independent Staging Quality Gate / publish (push) Has been skipped
feat(upstream): wire merged engine fields into chat and reports
Consultation and personal reports otherwise ignore the merged friendship table, timing seed, module audit, and Pratyantar windows.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-03 20:58:47 +08:00

107 lines
3.9 KiB
Python

"""Task 6: merged-engine fields on the commercial consultation path.
Fictional smoke data only. No birth-case files.
"""
from __future__ import annotations
from datetime import datetime
from scripts.consultation_engine_field_bridge import (
ASHTOTTARI_PARTIAL_NOTE,
attach_merged_engine_fields,
compact_planetary_friendship,
compact_pratyantar_timeline,
compact_timing_narrative,
extra_technique_audit_rows,
)
from scripts.jyotish_engine import _build_planetary_friendship_snapshot
SMOKE_PLANETS = {
"Sun": {"sign": "Capricorn"},
"Moon": {"sign": "Sagittarius"},
"Mars": {"sign": "Scorpio"},
"Mercury": {"sign": "Capricorn"},
"Jupiter": {"sign": "Gemini"},
"Venus": {"sign": "Aquarius"},
"Saturn": {"sign": "Capricorn"},
"Rahu": {"sign": "Aquarius"},
"Ketu": {"sign": "Leo"},
}
def test_friendship_compact_is_grade_table_only() -> None:
snapshot = _build_planetary_friendship_snapshot(SMOKE_PLANETS)
compact = compact_planetary_friendship(snapshot)
assert compact["rows"]
first = compact["rows"][0]
assert first["planet"] == "Sun"
assert set(first) == {
"planet", "great_friends", "friends", "neutral", "enemies", "great_enemies",
}
assert "headline" not in compact
assert "markdown" not in compact
def test_pratyantar_returns_current_and_next_boundaries() -> None:
sub_periods = {
"current": {
"mahadasha": {"lord": "Rahu", "start": "2011-11-11", "end": "2029-11-11"},
"antardasha": {"lord": "Sun", "start": "2026-05-30", "end": "2027-04-24"},
}
}
timeline = compact_pratyantar_timeline(sub_periods, datetime(2026, 9, 3))
assert timeline["status"] == "ready"
assert timeline["current"]["lord"]
assert timeline["current"]["start"] <= "2026-09-03" <= timeline["current"]["end"]
assert timeline["next"]["lord"]
assert timeline["next"]["start"] == timeline["current"]["end"]
def test_timing_narrative_clips_to_seed_caps() -> None:
payload = compact_timing_narrative({
"dasha_sub_periods": {
"current": {"mahadasha": {"lord": "Rahu"}},
}
})
assert payload["status"] != "blocked"
assert len(payload["headline"]) <= 300
assert len(payload["strengths"]) <= 8
assert all(len(item) <= 400 for item in payload["strengths"])
assert all(len(item) <= 400 for item in payload["boundaries"])
def test_ashtottari_audit_row_is_parameter_sensitive_not_certainty() -> None:
rows = extra_technique_audit_rows({"modules": {}})
by_name = {row["technique"]: row for row in rows}
assert by_name["Ashtottari Dasha"]["status"] == "partial"
assert by_name["Ashtottari Dasha"]["boundary"] == ASHTOTTARI_PARTIAL_NOTE
assert by_name["Planetary Friendship"]["status"] == "blocked"
assert by_name["Module Execution Audit"]["boundary"] == "附录可见;不得升格为确定性结论"
def test_attach_merged_fields_hangs_friendship_and_pratyantar() -> None:
chart = {
"planets": SMOKE_PLANETS,
"modules": {
"dasha_sub_periods": {
"current": {
"mahadasha": {"lord": "Rahu", "start": "2011-11-11", "end": "2029-11-11"},
"antardasha": {"lord": "Sun", "start": "2026-05-30", "end": "2027-04-24"},
}
}
},
}
attach_merged_engine_fields(chart, reference_dt=datetime(2026, 9, 3))
friendship = chart["modules"]["planetary_friendship"]
assert friendship["rows"]
pratyantar = chart["modules"]["pratyantar_dasha_timeline"]
assert pratyantar["status"] == "ready"
nested = chart["modules"]["dasha_sub_periods"]["pratyantar_dasha_timeline"]
assert nested["current"]["lord"] == pratyantar["current"]["lord"]
audit_rows = extra_technique_audit_rows(chart)
friendship_row = next(row for row in audit_rows if row["technique"] == "Planetary Friendship")
assert friendship_row["status"] == "executed"
assert "确定性" in friendship_row["boundary"]