Files
agent-zero/tests/test_intervention_llm_abort.py
linkliti 26ca0252d9 test(suite): align stubs and assertions with current behavior
Several test files still modeled older behavior: goal plugin stubs lacked the agent_name and context.log attributes the response tool reads, the intervention test built an AgentContext without id, startup asset assertions forbade the favicon link that safe and splash pages now ship, document query assertions pinned a superseded skill description, and the defer weakref check raced cyclic garbage collection. Stubs and assertions now match the code they cover. The welcome splash test asserted that the transparent background string appears nowhere in the welcome screen, which stopped holding once the reorderable layout menu gave its disabled buttons that background, so the check now inspects the welcome container block it was written for. The notification store test strips imports from the module it evaluates, which left the extension hook undefined once the store reported every received notification, so the harness now declares that hook.

Validation: full suite in a nested dev checkout fails 0, passes 3067, skips 7, down from 32 and 3029 at the first commit and 9 and 3058 after the path fix; pytest tests/test_webui_startup_assets.py tests/test_webui_message_ordering_static.py tests/test_ws_client_api_surface.py tests/test_defer_lifecycle.py tests/test_document_query_plugin.py tests/test_intervention_llm_abort.py plugins/_goal/tests/test_goal_plugin.py (67 passed).
2026-10-31 13:33:09 +03:00

60 lines
1.5 KiB
Python

from types import SimpleNamespace
from agent import AgentContext, UserMessage
def test_nudge_stops_running_context_and_starts_nudge_message():
context = AgentContext.__new__(AgentContext)
context.id = "nudge-context"
calls = []
class _Task:
def is_alive(self):
return False
def kill(self):
calls.append("kill")
context.task = _Task()
context.paused = True
context.streaming_agent = None
context.agent0 = SimpleNamespace(
intervention=None,
data={},
read_prompt=lambda _name: "nudge text",
)
started = {}
def fake_run_task(func, *args):
started["func"] = func
started["args"] = args
return "new-task"
context.run_task = fake_run_task
result = context.nudge()
assert calls == ["kill"]
assert result == "new-task"
assert started["args"][0] is context.agent0
assert started["args"][1].system_message == ["nudge text"]
assert started["args"][1].message == ""
def test_user_message_during_run_sets_intervention():
context = AgentContext.__new__(AgentContext)
current = SimpleNamespace(intervention=None, data={})
context.task = SimpleNamespace(is_alive=lambda: True)
context.paused = True
context.streaming_agent = current
context.agent0 = current
message = UserMessage("intervene")
context.communicate(message)
assert current.intervention is message
assert context.paused is False