Test: Added test cases for Add Chunk HTTP API (#6408)

### What problem does this PR solve?

cover [add
chunk](https://ragflow.io/docs/v0.17.2/http_api_reference#add-chunk)
endpoints

### Type of change

- [x] Add test cases
This commit is contained in:
liu an
2025-03-21 19:16:30 +08:00
committed by GitHub
parent 4091af4560
commit 8eefc8b5fe
4 changed files with 232 additions and 2 deletions

View File

@ -26,6 +26,7 @@ HOST_ADDRESS = os.getenv("HOST_ADDRESS", "http://127.0.0.1:9380")
DATASETS_API_URL = "/api/v1/datasets"
FILE_API_URL = "/api/v1/datasets/{dataset_id}/documents"
FILE_CHUNK_API_URL = "/api/v1/datasets/{dataset_id}/chunks"
CHUNK_API_URL = "/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks"
INVALID_API_TOKEN = "invalid_key_123"
DATASET_NAME_LIMIT = 128
@ -169,3 +170,12 @@ def stop_parse_documnet(auth, dataset_id, payload=None):
url = f"{HOST_ADDRESS}{FILE_CHUNK_API_URL}".format(dataset_id=dataset_id)
res = requests.delete(url=url, headers=HEADERS, auth=auth, json=payload)
return res.json()
# CHUNK MANAGEMENT WITHIN DATASET
def add_chunk(auth, dataset_id, document_id, payload=None):
url = f"{HOST_ADDRESS}{CHUNK_API_URL}".format(
dataset_id=dataset_id, document_id=document_id
)
res = requests.post(url=url, headers=HEADERS, auth=auth, json=payload)
return res.json()