Abid Ali Awan
Refactor test assertions in test_app.py to validate string outputs instead of dicts, and utilize handle_file for local file paths.
e29548e
raw
history blame
790 Bytes
from gradio_client import Client, handle_file
client = Client("http://127.0.0.1:7860/")
result_1 = client.predict(
local_file_path=handle_file("data/test-document.pdf"), output_format="docx", api_name="/predict"
)
print("Link to the document:", result_1)
assert (
isinstance(result_1, str)
and result_1 is not None # Check if the string itself is not None
and result_1.endswith(".docx")
)
result_2 = client.predict(
document_url="https://raw.githubusercontent.com/kingabzpro/bbc-news-class-mlops/refs/heads/master/README.md",
output_format="pdf",
api_name="/predict_1",
)
print("Link to the document:", result_2)
assert (
isinstance(result_2, str)
and result_2 is not None # Check if the string itself is not None
and result_2.endswith(".pdf")
)