Files
agent-radar 1a3a4ccde1
Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:01:50 +08:00

90 lines
3.3 KiB
Python

# -*- coding: utf-8 -*-
"""Integration tests for built-in tools API (scoped, no external keys)."""
from __future__ import annotations
import pytest
@pytest.mark.integration
@pytest.mark.p0
def test_agent_scoped_tools_toggle_and_async_execution_roundtrip(
app_server,
) -> None:
"""Test purpose:
- Verify agent-scoped tool PATCH endpoints toggle ``enabled`` and update
``async_execution`` with readback via GET list.
Test flow:
1. Create a dedicated test agent.
2. GET scoped tools list and pick the first built-in tool name.
3. Record baseline ``enabled`` and ``async_execution`` from that tool.
4. PATCH toggle twice (or once) to restore original ``enabled`` while
asserting each response matches the flipped value.
5. PATCH async_execution to the opposite value, GET list to confirm, then
restore baseline async_execution.
6. Delete test agent.
API endpoints:
- POST /api/agents
- GET /api/agents/{agentId}/tools
- PATCH /api/agents/{agentId}/tools/{tool_name}/toggle
- PATCH /api/agents/{agentId}/tools/{tool_name}/async-execution
- DELETE /api/agents/{agentId}
"""
agent_id = "integ_scoped_tools_01"
base = f"/api/agents/{agent_id}/tools"
create_agent = app_server.api_request(
"POST",
"/api/agents",
json={"id": agent_id, "name": "Scoped tools agent", "description": ""},
)
assert create_agent.status_code == 201, app_server.logs_tail()
try:
list_resp = app_server.api_request("GET", base)
assert list_resp.status_code == 200, app_server.logs_tail()
tools = list_resp.json()
assert isinstance(tools, list) and tools, app_server.logs_tail()
tool_name = str(tools[0]["name"])
baseline_enabled = bool(tools[0].get("enabled", True))
baseline_async = bool(tools[0].get("async_execution", False))
t1 = app_server.api_request(
"PATCH",
f"{base}/{tool_name}/toggle",
)
assert t1.status_code == 200, app_server.logs_tail()
assert bool(t1.json().get("enabled")) is (not baseline_enabled)
t2 = app_server.api_request(
"PATCH",
f"{base}/{tool_name}/toggle",
)
assert t2.status_code == 200, app_server.logs_tail()
assert bool(t2.json().get("enabled")) is baseline_enabled
target_async = not baseline_async
a1 = app_server.api_request(
"PATCH",
f"{base}/{tool_name}/async-execution",
json={"async_execution": target_async},
)
assert a1.status_code == 200, app_server.logs_tail()
assert bool(a1.json().get("async_execution")) is target_async
list_mid = app_server.api_request("GET", base)
assert list_mid.status_code == 200, app_server.logs_tail()
by_name = {item["name"]: item for item in list_mid.json()}
assert bool(by_name[tool_name].get("async_execution")) is target_async
a2 = app_server.api_request(
"PATCH",
f"{base}/{tool_name}/async-execution",
json={"async_execution": baseline_async},
)
assert a2.status_code == 200, app_server.logs_tail()
assert bool(a2.json().get("async_execution")) is baseline_async
finally:
app_server.api_request("DELETE", f"/api/agents/{agent_id}")