Skip to content

test(api): add unit tests for various control APIs#91

Merged
OhYee merged 1 commit intomainfrom
fix-sdk-breaking-change
Apr 22, 2026
Merged

test(api): add unit tests for various control APIs#91
OhYee merged 1 commit intomainfrom
fix-sdk-breaking-change

Conversation

@OhYee
Copy link
Copy Markdown
Member

@OhYee OhYee commented Apr 22, 2026

Added comprehensive unit tests for the AgentRuntimeControlAPI, CredentialControlAPI, KnowledgeBaseControlAPI, MemoryCollectionControlAPI, ModelControlAPI, SandboxControlAPI, ToolControlAPI, and ToolsetControlAPI. These tests ensure that the API methods correctly match the underlying SDK client method signatures, improving code reliability and maintainability.


新增各控制 API 的单元测试
为 AgentRuntimeControlAPI、CredentialControlAPI、KnowledgeBaseControlAPI、MemoryCollectionControlAPI、ModelControlAPI、SandboxControlAPI、ToolControlAPI 和 ToolsetControlAPI 添加了全面的单元测试。这些测试确保 API 方法与底层 SDK 客户端方法签名正确匹配,提高了代码的可靠性和可维护性。

Change-Id: I1d1f89ae1d9bc4c67e5d31bded1864b9790daa25

Thank you for creating a pull request to contribute to Serverless Devs agentrun-sdk-python code! Before you open the request please answer the following questions to help it be more easily integrated. Please check the boxes "[ ]" with "[x]" when done too.
Please select one of the PR types below to complete


Fix bugs

Bug detail

The specific manifestation of the bug or the associated issue.

Pull request tasks

  • Add test cases for the changes
  • Passed the CI test

Update docs

Reason for update

Why do you need to update your documentation?

Pull request tasks

  • Update Chinese documentation
  • Update English documentation

Add contributor

Contributed content

  • Code
  • Document

Content detail

if content_type == 'code' || content_type == 'document':
    please tell us `PR url`,like: https://github.com/Serverless-Devs/agentrun-sdk-python/pull/1
else:
    please describe your contribution in detail

Others

Reason for update

Why do you need to update your documentation?

Added comprehensive unit tests for the AgentRuntimeControlAPI, CredentialControlAPI, KnowledgeBaseControlAPI, MemoryCollectionControlAPI, ModelControlAPI, SandboxControlAPI, ToolControlAPI, and ToolsetControlAPI. These tests ensure that the API methods correctly match the underlying SDK client method signatures, improving code reliability and maintainability.

---
新增各控制 API 的单元测试
为 AgentRuntimeControlAPI、CredentialControlAPI、KnowledgeBaseControlAPI、MemoryCollectionControlAPI、ModelControlAPI、SandboxControlAPI、ToolControlAPI 和 ToolsetControlAPI 添加了全面的单元测试。这些测试确保 API 方法与底层 SDK 客户端方法签名正确匹配,提高了代码的可靠性和可维护性。

Change-Id: I1d1f89ae1d9bc4c67e5d31bded1864b9790daa25
Signed-off-by: OhYee <[email protected]>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds unit tests that validate the control-layer APIs invoke the underlying Alibaba Cloud SDK client methods with matching signatures, and updates the AgentRun SDK dependency and one generated control API to reflect updated SDK signatures.

Changes:

  • Added signature-verification unit tests for multiple *ControlAPI modules (sync + async), using create_autospec to enforce SDK method signatures.
  • Updated AgentRuntimeControlAPI generated code to match updated SDK method signatures (removed now-unneeded request objects for some endpoints).
  • Bumped alibabacloud-agentrun20250910 minimum version to >=5.6.3.

Reviewed changes

Copilot reviewed 10 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unittests/agent_runtime/api/test_control.py Adds autospec-based signature tests for AgentRuntime control APIs (sync/async).
tests/unittests/credential/api/test_control.py Adds autospec-based signature tests for Credential control APIs (sync/async).
tests/unittests/credential/api/init.py Test package init for credential API tests.
tests/unittests/knowledgebase/api/test_control.py Adds autospec-based signature tests for KnowledgeBase control APIs (sync/async).
tests/unittests/memory_collection/api/test_control.py Adds autospec-based signature tests for MemoryCollection control APIs (sync/async).
tests/unittests/memory_collection/api/init.py Test package init for memory_collection API tests.
tests/unittests/model/api/test_control.py Adds autospec-based signature tests for Model control APIs (service/proxy, sync/async).
tests/unittests/sandbox/api/test_control.py Adds autospec-based signature tests for Sandbox control APIs (sync/async).
tests/unittests/tool/api/test_control.py Adds autospec-based signature tests for Tool control APIs (sync/async).
tests/unittests/tool/api/init.py Test package init for tool API tests.
tests/unittests/toolset/api/test_control.py Adds autospec-based signature tests for toolset control API using DevsClient (sync/async).
pyproject.toml Bumps alibabacloud-agentrun20250910 dependency to >=5.6.3.
agentrun/agent_runtime/api/control.py Adjusts generated AgentRuntime control calls to match updated SDK signatures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +12 to +14

from agentrun.toolset.api.control import ToolControlAPI
from agentrun.utils.config import Config
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR 描述中提到的是 “ToolsetControlAPI”,但此处实际被测对象与实现类名是 agentrun.toolset.api.control.ToolControlAPI。为避免读者误解(尤其是 tool vs toolset 两条链路同时存在),建议统一命名:要么在 PR 描述/测试类名中使用 ToolControlAPI(toolset),要么在代码生成/导出层提供 ToolsetControlAPI 的别名。

Copilot uses AI. Check for mistakes.
@OhYee OhYee merged commit 6df652b into main Apr 22, 2026
6 checks passed
@OhYee OhYee deleted the fix-sdk-breaking-change branch April 22, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants