File size: 904 Bytes
0b083c6 7d8d72d 0b083c6 7d8d72d 0b083c6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | """Simple smoke test for the diacritization API."""
import os
import sys
import requests
BASE = os.getenv("API_BASE", "http://localhost:8000")
HEADERS = {"Content-Type": "application/json"}
if key := os.getenv("API_KEY"):
HEADERS["X-API-Key"] = key
def main() -> int:
health = requests.get(f"{BASE}/health", timeout=30)
health.raise_for_status()
print("health:", health.json())
payload = {"text": "كتب الطالب الدرس"}
response = requests.post(f"{BASE}/diacritize", json=payload, headers=HEADERS, timeout=120)
response.raise_for_status()
data = response.json()
assert "diacritized" in data, data
print("diacritize:", data)
return 0
if __name__ == "__main__":
try:
raise SystemExit(main())
except requests.RequestException as exc:
print(f"Request failed: {exc}", file=sys.stderr)
raise SystemExit(1) from exc
|