feat(tarot-lab): prompt.py + schema.py 이관 + 검증 테스트 6건

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-25 18:26:08 +09:00
parent 387d2465b0
commit a94c73b134
3 changed files with 203 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
from app.schema import validate_interpretation
def _valid_card():
return {
"position": "과거", "card": "the-fool", "reversed": False,
"interpretation": "...", "advice": "...",
"evidence": {
"card_meaning_used": "새 시작",
"position_logic": "...",
"category_lens": "...",
},
}
def _valid_payload():
return {
"summary": "...",
"cards": [_valid_card()],
"interactions": [{"type": "synergy", "between": ["a", "b"], "explanation": "..."}],
"advice": "...",
"confidence": "medium",
}
def test_valid_three_card():
ok, _ = validate_interpretation(_valid_payload(), "three_card")
assert ok is True
def test_missing_summary():
p = _valid_payload(); del p["summary"]
ok, err = validate_interpretation(p, "three_card")
assert not ok and "summary" in err
def test_invalid_confidence():
p = _valid_payload(); p["confidence"] = "extreme"
ok, err = validate_interpretation(p, "three_card")
assert not ok and "confidence" in err
def test_three_card_empty_interactions():
p = _valid_payload(); p["interactions"] = []
ok, err = validate_interpretation(p, "three_card")
assert not ok and "interactions" in err
def test_one_card_empty_interactions_ok():
p = _valid_payload(); p["interactions"] = []
ok, _ = validate_interpretation(p, "one_card")
assert ok is True
def test_card_evidence_missing_field():
p = _valid_payload()
del p["cards"][0]["evidence"]["category_lens"]
ok, err = validate_interpretation(p, "three_card")
assert not ok and "category_lens" in err