Files
NotesAgentic/backend/tests/test_api.py
T
admin b71984d951 实现 AI Core 与 Agent Core 基础功能
- 更新 README 描述从后端壳子到 AI Core/Agent Core
- 添加 ToolCall 和 ToolResult 数据结构定义
- 扩展 AgentRun 模型增加输出、错误码、工具调用结果等字段
- 添加 mock 提供商类型支持
- 实现聊天、代理运行、工具调用和提供商管理的核心路由逻辑
- 集成容器化依赖注入和错误处理机制
- 更新 API 接口契约和文档说明
2026-08-27 13:55:00 +08:00

56 lines
1.6 KiB
Python

import asyncio
from app.main import health, service_status
from app.routes import get_index_status, list_notes, list_plugins, list_providers, list_skills
def test_health() -> None:
response = asyncio.run(health())
assert response.model_dump() == {"status": "ok"}
def test_service_status() -> None:
response = asyncio.run(service_status())
assert response.name == "Notes Agent AI Core"
assert response.status == "ok"
def test_query_shells_are_empty_and_typed() -> None:
notes = asyncio.run(list_notes(limit=20, offset=0, folder=None, tag=None))
skills = asyncio.run(list_skills())
plugins = asyncio.run(list_plugins())
providers = asyncio.run(list_providers())
index = asyncio.run(get_index_status())
assert notes.items == []
assert notes.page.limit == 20
assert skills.items == []
assert plugins.items == []
assert [provider.provider_id for provider in providers.items] == ["mock"]
assert index.status == "idle"
def test_openapi_contains_documented_frontend_interfaces() -> None:
from app.main import app
paths = app.openapi()["paths"]
expected_paths = {
"/api/notes/{note_id}",
"/api/search",
"/api/chat",
"/api/agent/runs",
"/api/agent/runs/{run_id}/cancel",
"/api/agent/runs/{run_id}/events",
"/api/skills",
"/api/plugins",
"/api/plugins/install",
"/api/plugins/{plugin_id}/enable",
"/api/plugins/{plugin_id}/disable",
"/api/providers/test",
"/api/index/rebuild",
}
assert expected_paths <= paths.keys()