-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_interaction.py
More file actions
56 lines (45 loc) · 1.49 KB
/
test_interaction.py
File metadata and controls
56 lines (45 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from unittest.mock import patch
from dreadnode.agent.tools.interaction import Question, QuestionOption, ask_user
def test_question_model() -> None:
q = Question(
id="test",
question="Test question?",
options=[
QuestionOption(label="Option 1", description="First option"),
QuestionOption(label="Option 2", description="Second option"),
],
)
assert q.id == "test"
assert len(q.options) == 2
assert q.multi_select is False
def test_ask_user_single_choice() -> None:
questions = [
{
"id": "choice",
"question": "Pick one",
"options": [
{"label": "A", "description": "First"},
{"label": "B", "description": "Second"},
],
}
]
with patch("builtins.input", return_value="1"), patch("builtins.print"):
result = ask_user(questions)
assert "choice: A" in result
def test_ask_user_multi_choice() -> None:
questions = [
{
"id": "choices",
"question": "Pick multiple",
"options": [
{"label": "A", "description": "First"},
{"label": "B", "description": "Second"},
{"label": "C", "description": "Third"},
],
"multi_select": True,
}
]
with patch("builtins.input", return_value="1,3"), patch("builtins.print"):
result = ask_user(questions)
assert "A" in result
assert "C" in result