Import project files
This commit is contained in:
50
docling/app/tests/run_minio_presign_debug.py
Normal file
50
docling/app/tests/run_minio_presign_debug.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import io
|
||||
from fastapi.testclient import TestClient
|
||||
import sys
|
||||
from pathlib import Path as _Path
|
||||
base = _Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(base))
|
||||
sys.path.insert(0, str(base / "docling"))
|
||||
import app.server as server
|
||||
|
||||
|
||||
class FakeMinio:
|
||||
def __init__(self):
|
||||
pass
|
||||
def get_presigned_url(self, method: str, bucket: str, obj: str, expires: int):
|
||||
return f"http://minio.test/presigned/{bucket}/{obj}?e={expires}"
|
||||
def presigned_get_object(self, bucket: str, obj: str, expires: int):
|
||||
return f"http://minio.test/presigned/{bucket}/{obj}?e={expires}"
|
||||
|
||||
|
||||
def setup():
|
||||
server.RUNTIME_CONFIG["minio"].update({
|
||||
"endpoint": "127.0.0.1:9000",
|
||||
"public": "http://127.0.0.1:9000",
|
||||
"access": "ak",
|
||||
"secret": "sk",
|
||||
"bucket": "doctest",
|
||||
"secure": "false",
|
||||
"prefix": "assets",
|
||||
"store_final": "true",
|
||||
"public_read": "true",
|
||||
})
|
||||
fake = FakeMinio()
|
||||
def _cur():
|
||||
return fake, "doctest", "http://127.0.0.1:9000", "assets"
|
||||
server._minio_current = _cur # type: ignore
|
||||
|
||||
|
||||
def run():
|
||||
setup()
|
||||
app = server.app
|
||||
c = TestClient(app)
|
||||
url = "http://127.0.0.1:9000/doctest/assets/rewritten/%E6%B5%8B%E8%AF%95/a.md"
|
||||
r = c.post("/minio/presign", data={"url": url, "expires": 7200})
|
||||
print("status:", r.status_code)
|
||||
print(r.json())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
|
||||
Reference in New Issue
Block a user