enforce repository local yoga and prashna tests

This commit is contained in:
732642856
2026-07-15 13:52:05 +08:00
parent 1534d827be
commit beea0f1996
5 changed files with 30 additions and 34 deletions
+10 -7
View File
@@ -1,18 +1,21 @@
"""
自动化 Yoga 测试运行器 — 从 yoga_test_suite.json 加载用例并批量验证
"""
import json, sys, os
SKILL_DIR = '<home>/.workbuddy/skills/jyotish-vedic-astrology'
sys.path.insert(0, os.path.join(SKILL_DIR, 'scripts'))
RULES_PATH = os.path.join(SKILL_DIR, 'references', 'yoga_rules.json')
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'scripts'))
RULES_PATH = ROOT / 'references' / 'yoga_rules.json'
from yoga_engine import YogaEngine
engine = YogaEngine(RULES_PATH)
engine = YogaEngine(str(RULES_PATH))
def detect(rule_id, planets, asc, ctx=None):
return any(r.get('rule_id') == rule_id for r in engine.detect(planets, asc, context=ctx))
suite_path = os.path.join(SKILL_DIR, 'tests', 'yoga_test_suite.json')
with open(suite_path) as f:
suite_path = ROOT / 'tests' / 'yoga_test_suite.json'
with suite_path.open() as f:
suite = json.load(f)
passed = 0
+8 -22
View File
@@ -908,33 +908,19 @@ def test_prashna_rejects_non_string_question() -> None:
handler._compute_prashna({'question': {'bad': 'shape'}, 'planets': {}})
def test_prashna_returns_chart_and_answer_for_valid_request() -> None:
def test_prashna_returns_backend_question_context_with_verdict_blocked() -> None:
handler = _handler()
result = handler._compute_prashna({
'question': 'career',
'question_text': '这个工作机会是否值得争取?',
'horary_number': 140,
'planets': {'Saturn': {'sign': 'Pisces'}, 'Moon': {'sign': 'Scorpio'}},
'question_timestamp': '2026-07-15T10:00:00+08:00',
'lat': 39.9042,
'lon': 116.4074,
'timezone': 8,
})
assert 'prashna_chart' in result
assert 'kp_answer' in result
assert result['kp_answer']['question_type'] == 'career'
assert result['kp_answer_v2']['primary_house'] == 10
assert 'arudha' in result
assert 'sphutas' in result
assert 'sahams' in result
assert 'lost_item' in result
assert 'kunda' in result
kp_horary = result['kp_horary']
assert kp_horary['method'] == 'KP Horary'
assert kp_horary['horary_number'] == 140
assert kp_horary['question_houses']['primary'] == 10
assert kp_horary['ruling_planets']['ascendant_lord']
assert kp_horary['ruling_planets']['moon_star_lord']
assert kp_horary['cuspal_sub_lord']['house'] == 10
assert kp_horary['cuspal_sub_lord']['kp_lords']['sub_lord']
assert kp_horary['house_significators']['10']
assert kp_horary['judgement_matrix']
assert result['status'] == 'computed'
assert result['prashna_context']['chart_source'] == 'swiss_ephemeris_backend'
assert result['verdict']['status'] == 'blocked'
def test_prashna_advanced_legacy_functions_exist() -> None:
+7 -5
View File
@@ -1,12 +1,14 @@
"""
PyJHora 风格硬编码 Yoga True/False 测试
"""
import sys, os
SKILL_DIR = '<home>/.workbuddy/skills/jyotish-vedic-astrology'
sys.path.insert(0, os.path.join(SKILL_DIR, 'scripts'))
RULES_PATH = os.path.join(SKILL_DIR, 'references', 'yoga_rules.json')
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'scripts'))
RULES_PATH = ROOT / 'references' / 'yoga_rules.json'
from yoga_engine import YogaEngine
engine = YogaEngine(RULES_PATH)
engine = YogaEngine(str(RULES_PATH))
def detect(rule_id, planets, ascendant, context=None):
results = engine.detect(planets, ascendant, context=context)