Improve KB upload

This commit is contained in:
Xin Wang
2026-02-10 10:50:47 +08:00
parent 375181a524
commit 30f757529f
3 changed files with 177 additions and 22 deletions

View File

@@ -120,6 +120,19 @@ class TestKnowledgeAPI:
assert "id" in data
assert data["status"] == "pending"
def test_upload_file_auto_index(self, client):
"""Test uploading a real file triggers auto indexing."""
create_response = client.post("/api/knowledge/bases", json={"name": "Auto Index KB"})
kb_id = create_response.json()["id"]
content = "Line one about product.\nLine two about warranty."
files = {"file": ("auto-index.txt", content.encode("utf-8"), "text/plain")}
response = client.post(f"/api/knowledge/bases/{kb_id}/documents", files=files)
assert response.status_code == 200
data = response.json()
assert data["status"] == "completed"
assert data["chunkCount"] >= 1
def test_delete_document(self, client):
"""Test deleting a document from knowledge base"""
# Create KB first