chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Tests for the update_knowledge_from_text MCP tool and client method."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import academy_mcp_server as srv
|
||||
|
||||
|
||||
class UpdateKnowledgeFromTextTest(unittest.TestCase):
|
||||
def test_client_puts_manual_update_to_expected_endpoint(self):
|
||||
client = srv.AcademyClient("http://localhost:8080/api/v1", "k")
|
||||
with mock.patch.object(client, "_request") as req:
|
||||
req.return_value = {"ok": True}
|
||||
result = client.update_knowledge_from_text(
|
||||
"knowledge-1", "# Updated", title="New title"
|
||||
)
|
||||
|
||||
self.assertEqual(result, {"ok": True})
|
||||
req.assert_called_once_with(
|
||||
"PUT",
|
||||
"/knowledge/manual/knowledge-1",
|
||||
json={
|
||||
"title": "New title",
|
||||
"content": "# Updated",
|
||||
"status": "publish",
|
||||
},
|
||||
)
|
||||
|
||||
def test_client_can_save_a_draft_and_keep_the_title(self):
|
||||
client = srv.AcademyClient("http://localhost:8080/api/v1", "k")
|
||||
with mock.patch.object(client, "_request") as req:
|
||||
req.return_value = {"ok": True}
|
||||
client.update_knowledge_from_text(
|
||||
"knowledge-1", "Draft content", status="draft"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
req.call_args.kwargs["json"],
|
||||
{"title": "", "content": "Draft content", "status": "draft"},
|
||||
)
|
||||
|
||||
def test_tool_forwards_all_update_fields(self):
|
||||
with mock.patch.object(
|
||||
srv.client, "update_knowledge_from_text", return_value={"ok": True}
|
||||
) as method:
|
||||
result = srv.update_knowledge_from_text(
|
||||
"knowledge-1", "Body", title="Title", status="draft"
|
||||
)
|
||||
|
||||
self.assertEqual(result, {"ok": True})
|
||||
method.assert_called_once_with(
|
||||
"knowledge-1", "Body", title="Title", status="draft"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user