Files
ai-agent-book/chapter4/perception-tools/test_search_kb_negative_top_k.py
liqiang b119135836
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
2026-08-20 13:12:50 +00:00

20 lines
653 B
Python

import json
from pathlib import Path
import pytest
import sys
sys.path.insert(0, str(Path(__file__).parent / "src"))
from search_tools import search_knowledge_base
@pytest.mark.asyncio
async def test_search_knowledge_base_negative_top_k(tmp_path: Path):
(tmp_path / "doc1.txt").write_text("test content one", encoding="utf-8")
(tmp_path / "doc2.txt").write_text("test content two", encoding="utf-8")
res = await search_knowledge_base("test", str(tmp_path), top_k=-1)
payload = json.loads(res.text)
assert payload["success"] is True
assert payload["message"]["total_found"] == 0
assert payload["message"]["results"] == []