Test: Added test cases for Download Documents HTTP API (#6032)

### What problem does this PR solve?

cover [download docments
endpoints](https://ragflow.io/docs/dev/http_api_reference#download-document)

### Type of change

- [x] add test cases
This commit is contained in:
liu an
2025-03-13 18:32:57 +08:00
committed by GitHub
parent baf3b9be7c
commit 0a877941f4
5 changed files with 271 additions and 34 deletions

View File

@ -15,6 +15,7 @@
#
import base64
import hashlib
from pathlib import Path
@ -23,3 +24,14 @@ def encode_avatar(image_path):
binary_data = file.read()
base64_encoded = base64.b64encode(binary_data).decode("utf-8")
return base64_encoded
def compare_by_hash(file1, file2, algorithm="sha256"):
def _calc_hash(file_path):
hash_func = hashlib.new(algorithm)
with open(file_path, "rb") as f:
while chunk := f.read(8192):
hash_func.update(chunk)
return hash_func.hexdigest()
return _calc_hash(file1) == _calc_hash(file2)