56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
# retoor <retoor@molodetz.nl>
|
|||
|
|
|
||
|
|
from devplacepy.services.devii.agents.actions import AGENT_ACTIONS
|
||
|
|
|
||
|
|
|
||
|
|
def _by_name():
|
||
|
|
return {action.name: action for action in AGENT_ACTIONS}
|
||
|
|
|
||
|
|
|
||
|
|
def test_six_agent_tools_with_agent_handler():
|
||
|
|
assert sorted(_by_name()) == [
|
||
|
|
"agent_cancel",
|
||
|
|
"agent_list",
|
||
|
|
"agent_result",
|
||
|
|
"agent_start",
|
||
|
|
"agent_status",
|
||
|
|
"ask_user",
|
||
|
|
]
|
||
|
|
for action in AGENT_ACTIONS:
|
||
|
|
assert action.handler == "agent"
|
||
|
|
assert action.method == "LOCAL"
|
||
|
|
assert action.summary.strip()
|
||
|
|
|
||
|
|
|
||
|
|
def test_auth_mirrors_tasks():
|
||
|
|
tools = _by_name()
|
||
|
|
assert tools["agent_start"].requires_auth is True
|
||
|
|
assert tools["agent_cancel"].requires_auth is True
|
||
|
|
assert tools["agent_status"].requires_auth is False
|
||
|
|
assert tools["agent_result"].requires_auth is False
|
||
|
|
assert tools["agent_list"].requires_auth is False
|
||
|
|
assert tools["ask_user"].requires_auth is False
|
||
|
|
|
||
|
|
|
||
|
|
def test_start_carries_the_four_part_contract():
|
||
|
|
params = {p.name: p for p in _by_name()["agent_start"].params}
|
||
|
|
assert params["category"].required is True
|
||
|
|
assert params["task"].required is True
|
||
|
|
assert params["output_format"].required is True
|
||
|
|
assert params["tools_extra"].type == "array"
|
||
|
|
assert "label" in params
|
||
|
|
assert "budget_hint" in params
|
||
|
|
|
||
|
|
|
||
|
|
def test_result_resumes_with_an_answer():
|
||
|
|
params = {p.name: p for p in _by_name()["agent_result"].params}
|
||
|
|
assert params["uid"].required is True
|
||
|
|
assert params["answer"].required is False
|
||
|
|
|
||
|
|
|
||
|
|
def test_uid_params_are_required():
|
||
|
|
tools = _by_name()
|
||
|
|
for name in ("agent_status", "agent_cancel"):
|
||
|
|
params = {p.name: p for p in tools[name].params}
|
||
|
|
assert params["uid"].required is True
|