feat(agent-office): Tarot 응답 스키마 검증 (T4)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
75
agent-office/tests/test_tarot_schema.py
Normal file
75
agent-office/tests/test_tarot_schema.py
Normal file
@@ -0,0 +1,75 @@
|
||||
import pytest
|
||||
|
||||
from app.tarot.schema import validate_interpretation
|
||||
|
||||
|
||||
def _valid_three():
|
||||
return {
|
||||
"summary": "S",
|
||||
"cards": [
|
||||
{"position": "과거", "card": "the-fool", "reversed": False,
|
||||
"interpretation": "...", "advice": "a",
|
||||
"evidence": {"card_meaning_used": "키워드", "position_logic": "p", "category_lens": "c"}},
|
||||
{"position": "현재", "card": "the-lovers", "reversed": True,
|
||||
"interpretation": "...", "advice": "a",
|
||||
"evidence": {"card_meaning_used": "키워드", "position_logic": "p", "category_lens": "c"}},
|
||||
{"position": "미래", "card": "ten-of-cups", "reversed": False,
|
||||
"interpretation": "...", "advice": "a",
|
||||
"evidence": {"card_meaning_used": "키워드", "position_logic": "p", "category_lens": "c"}},
|
||||
],
|
||||
"interactions": [{"type": "synergy", "between": ["the-fool", "ten-of-cups"], "explanation": "..."}],
|
||||
"advice": "A",
|
||||
"warning": None,
|
||||
"confidence": "medium",
|
||||
}
|
||||
|
||||
|
||||
def test_valid_three_card_passes():
|
||||
ok, msg = validate_interpretation(_valid_three(), "three_card")
|
||||
assert ok, msg
|
||||
|
||||
|
||||
def test_missing_evidence_fails():
|
||||
bad = _valid_three()
|
||||
del bad["cards"][0]["evidence"]
|
||||
ok, msg = validate_interpretation(bad, "three_card")
|
||||
assert not ok
|
||||
assert "evidence" in msg
|
||||
|
||||
|
||||
def test_empty_card_meaning_used_fails():
|
||||
bad = _valid_three()
|
||||
bad["cards"][0]["evidence"]["card_meaning_used"] = ""
|
||||
ok, msg = validate_interpretation(bad, "three_card")
|
||||
assert not ok
|
||||
assert "card_meaning_used" in msg
|
||||
|
||||
|
||||
def test_three_card_requires_interactions():
|
||||
bad = _valid_three()
|
||||
bad["interactions"] = []
|
||||
ok, msg = validate_interpretation(bad, "three_card")
|
||||
assert not ok
|
||||
assert "interactions" in msg
|
||||
|
||||
|
||||
def test_one_card_accepts_empty_interactions():
|
||||
one = {
|
||||
"summary": "S",
|
||||
"cards": [{"position": "오늘", "card": "the-fool", "reversed": False,
|
||||
"interpretation": "...", "advice": "a",
|
||||
"evidence": {"card_meaning_used": "k", "position_logic": "p", "category_lens": "c"}}],
|
||||
"interactions": [],
|
||||
"advice": "A",
|
||||
"warning": None,
|
||||
"confidence": "high",
|
||||
}
|
||||
ok, msg = validate_interpretation(one, "one_card")
|
||||
assert ok, msg
|
||||
|
||||
|
||||
def test_invalid_confidence_fails():
|
||||
bad = _valid_three()
|
||||
bad["confidence"] = "very high"
|
||||
ok, msg = validate_interpretation(bad, "three_card")
|
||||
assert not ok
|
||||
Reference in New Issue
Block a user