Refa: migrate chunk APIs to RESTful routes (#14291)

### What problem does this PR solve?

migrate chunk APIs to RESTful routes

### Type of change
- [x] Refactoring
This commit is contained in:
buua436
2026-04-23 14:17:23 +08:00
committed by GitHub
parent 76b017ca32
commit 7817b0d779
30 changed files with 1594 additions and 2237 deletions

View File

@@ -212,18 +212,17 @@ class TestDeleteQueryConstruction:
assert len(kw_terms) == 1
class TestChunkAppDeleteCondition:
class TestChunkApiDeleteCondition:
"""
Tests that verify the chunk_app.py rm endpoint passes the correct
Tests that verify the RESTful chunk DELETE endpoint passes the correct
condition to docStoreConn.delete.
"""
def test_rm_endpoint_includes_doc_id_in_condition(self):
"""
The /chunk/rm endpoint MUST include doc_id in the condition
The /api/v1/datasets/<dataset_id>/documents/<document_id>/chunks endpoint
MUST include doc_id in the condition
passed to settings.docStoreConn.delete.
This is the fix applied to api/apps/chunk_app.py
"""
# Simulate what the rm endpoint should construct
req = {
@@ -248,7 +247,7 @@ class TestChunkAppDeleteCondition:
class TestSDKDocDeleteCondition:
"""
Tests that verify the SDK doc.py rm_chunk endpoint constructs
Tests that verify the RESTful chunk delete endpoint constructs
the correct deletion condition.
"""
@@ -261,7 +260,7 @@ class TestSDKDocDeleteCondition:
document_id = "doc456"
chunk_ids = ["chunk1", "chunk2"]
# The CORRECT condition construction (from sdk/doc.py):
# The CORRECT condition construction (from restful_apis/chunk_api.py):
condition = {"doc_id": document_id}
if chunk_ids:
condition["id"] = chunk_ids