You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
mulit-agent/mulit_agent/tests/test_full_access_tool.py

54 lines
1.7 KiB

from mulit_agent_app.infrastructure.full_access_tool import FullAccessTool
def test_full_access_tool_runs_a_local_powershell_command():
tool = FullAccessTool()
result = tool.execute("task-1", "Write-Output full-access-ok")
assert result == "full-access-ok"
def test_full_access_tool_redacts_secrets_from_command_output():
tool = FullAccessTool()
result = tool.execute("task-2", "Write-Output 'api_key=must-not-leave-agent'")
assert "must-not-leave-agent" not in result
assert "[已脱敏]" in result
def test_full_access_tool_hides_the_powershell_window(monkeypatch):
calls: list[dict[str, object]] = []
class Process:
returncode = 0
def communicate(self):
return "done", ""
def fake_popen(*_args, **kwargs):
calls.append(kwargs)
return Process()
monkeypatch.setattr("mulit_agent_app.infrastructure.full_access_tool.subprocess.Popen", fake_popen)
monkeypatch.setattr("mulit_agent_app.infrastructure.full_access_tool.subprocess.CREATE_NO_WINDOW", 42, raising=False)
assert FullAccessTool().execute("task-hidden", "Write-Output done") == "done"
assert calls[0]["creationflags"] == 42
def test_full_access_tool_stages_and_removes_task_attachments():
from mulit_agent_app.domain.attachments import TaskAttachment
tool = FullAccessTool()
paths = tool.stage_attachments(
"test-staged-attachment",
(TaskAttachment("input.png", "image/png", "data:image/png;base64,aW1hZ2U="),),
)
assert len(paths) == 1
assert paths[0].name == "input.png"
assert paths[0].read_bytes() == b"image"
tool.cleanup_task_attachments("test-staged-attachment")
assert not paths[0].exists()