60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
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
|