20 lines
644 B
Python
20 lines
644 B
Python
|
|
from app.services.voice_confirm import build_prompt_text, parse_voice_choice
|
||
|
|
|
||
|
|
|
||
|
|
def test_parse_voice_choice_substring() -> None:
|
||
|
|
assert parse_voice_choice("用的是纱布对吧", ["纱布", "缝线"]) == "纱布"
|
||
|
|
|
||
|
|
|
||
|
|
def test_parse_voice_choice_numeric() -> None:
|
||
|
|
assert parse_voice_choice("第2个", ["纱布", "缝线", "钳子"]) == "缝线"
|
||
|
|
|
||
|
|
|
||
|
|
def test_parse_voice_choice_negative() -> None:
|
||
|
|
assert parse_voice_choice("不是", ["纱布", "缝线"]) is None
|
||
|
|
|
||
|
|
|
||
|
|
def test_build_prompt_contains_options() -> None:
|
||
|
|
text = build_prompt_text([("纱布", 0.4), ("缝线", 0.3)])
|
||
|
|
assert "纱布" in text
|
||
|
|
assert "缝线" in text
|