-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cli.py
More file actions
137 lines (117 loc) · 4.14 KB
/
Copy pathtest_cli.py
File metadata and controls
137 lines (117 loc) · 4.14 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
"""Integration tests for HungryCall CLI."""
import json
from hungrycall.cli import main
def test_cli_delivery_dry_run(capsys):
ret = main([
"delivery",
"--food", "Burger",
"--address", "Hauptstraße 12",
"--budget", "35.0",
"--scenario", "success_direct"
])
assert ret == 0
captured = capsys.readouterr()
assert "HUNGRYCALL — Cascade Agent Execution" in captured.out
assert "RESULT: SUCCESS" in captured.out
assert "Ordered from Burger House Dorfstadt" in captured.out
def test_cli_delivery_json_output(capsys):
ret = main([
"delivery",
"--food", "Burger",
"--address", "Hauptstraße 12",
"--budget", "35.0",
"--scenario", "success_direct",
"--json-output"
])
assert ret == 0
captured = capsys.readouterr()
parsed = json.loads(captured.out)
assert parsed["success"] is True
assert parsed["mode"] == "delivery"
assert len(parsed["attempts"]) == 1
def test_cli_budget_exceeded_scenario(capsys):
ret = main([
"delivery",
"--food", "Burger",
"--address", "Hauptstraße 12",
"--budget", "35.0",
"--scenario", "budget_exceeded_cascade"
])
assert ret == 0
captured = capsys.readouterr()
assert "Attempt #1: Burger House Dorfstadt" in captured.out
assert "exceeds maximum budget limit" in captured.out
assert "Attempt #2: Trattoria Bella Luigi" in captured.out
assert "RESULT: SUCCESS" in captured.out
def test_cli_reservation_accepts_custom_table_and_bounded_authority(capsys):
"""The new table criteria are reachable from the CLI too."""
granted = main([
"reservation", "--food", "Italian", "--date", "2026-08-07",
"--time", "19:00", "--party", "4", "--seating", "custom",
"--seating-custom", "our table under the palm",
"--earlier-hours", "1", "--later-minutes", "30",
"--max-booking-fee-eur", "3", "--note", "birthday dinner",
"--scenario", "reservation_cascade",
])
assert granted == 0
out = capsys.readouterr().out
assert "RESULT: SUCCESS" in out
assert "Trattoria Bella Luigi" in out
def test_cli_reservation(capsys):
ret = main([
"reservation",
"--food", "Italian",
"--date", "2026-08-05",
"--time", "19:00",
"--party", "4",
"--scenario", "reservation_cascade"
])
assert ret == 0
captured = capsys.readouterr()
assert "Table reserved at Trattoria Bella Luigi" in captured.out
def test_cli_pickup(capsys):
ret = main([
"pickup",
"--food", "Burger",
"--budget", "25.0",
"--scenario", "pickup_cascade"
])
assert ret == 0
captured = capsys.readouterr()
assert "Pickup order placed at Burger House Dorfstadt" in captured.out
def test_cli_live_without_confirm_fails(capsys):
ret = main([
"delivery",
"--food", "Burger",
"--address", "Hauptstraße 12",
"--budget", "35.0",
"--live"
])
assert ret == 2
captured = capsys.readouterr()
assert "ERROR: Live execution requires explicit confirmation" in captured.err
def test_cli_confirmed_live_requires_human_callback_before_credentials(capsys):
ret = main([
"delivery",
"--food", "Burger",
"--address", "Hauptstraße 12",
"--budget", "35.0",
"--live",
"--confirm-live",
])
assert ret == 2
captured = capsys.readouterr()
assert "requires --requester-callback-number" in captured.err
def test_cli_demo_subcommand(capsys):
ret = main(["demo"])
assert ret == 0
captured = capsys.readouterr()
assert "HUNGRYCALL — Cascade Agent Execution" in captured.out
assert "Attempt #1: Trattoria Bella Luigi" in captured.out
assert "Unclear price statement" in captured.out
assert "Attempt #2: Burger House Dorfstadt" in captured.out
assert "exceeds maximum budget limit" in captured.out
assert "Attempt #3: Asia Wok Express" in captured.out
assert "RESULT: SUCCESS" in captured.out
assert "Ordered from Asia Wok Express" in captured.out
assert "Verification Transcript (Order Proof):" in captured.out