mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Test: Added test cases for Parse Documents HTTP API (#6235)
### What problem does this PR solve? cover [parse documents](https://ragflow.io/docs/dev/http_api_reference#parse-documents) endpoints ### Type of change - [x] add test cases
This commit is contained in:
@ -15,7 +15,9 @@
|
||||
#
|
||||
|
||||
import base64
|
||||
import functools
|
||||
import hashlib
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@ -35,3 +37,22 @@ def compare_by_hash(file1, file2, algorithm="sha256"):
|
||||
return hash_func.hexdigest()
|
||||
|
||||
return _calc_hash(file1) == _calc_hash(file2)
|
||||
|
||||
|
||||
def wait_for(timeout=10, interval=1, error_msg="Timeout"):
|
||||
def decorator(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
start_time = time.time()
|
||||
while True:
|
||||
result = func(*args, **kwargs)
|
||||
if result is True:
|
||||
return result
|
||||
elapsed = time.time() - start_time
|
||||
if elapsed > timeout:
|
||||
assert False, error_msg
|
||||
time.sleep(interval)
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
|
||||
Reference in New Issue
Block a user