intern_assignment / test_adjudication.py
Battlecon's picture
Initial clean deployment commit
05cb41b
Raw
History Blame Contribute Delete
1.62 kB
import os
import requests
import json
# Target URL for your local running FastAPI instance
URL = "http://127.0.0.1:8000/api/claims/adjudicate"
# Pick one of the sample images available in your folder
IMAGE_FILE = "111.jpg" # You can swap this with '111.jpg', '115.jpg', or 'handwriting.png'
def run_test():
if not os.path.exists(IMAGE_FILE):
print(f"❌ Error: Test image '{IMAGE_FILE}' not found in the root folder.")
return
print(f"πŸš€ Sending claim adjudication request for document: {IMAGE_FILE}...")
# Form fields required by our FastAPI route
form_data = {
"member_id": "Sudhan P",
"claim_amount": "4500.00",
"cashless_request": "false",
"hospital_name": "Apollo Hospital"
}
# Open and attach the document image
with open(IMAGE_FILE, "rb") as f:
files = {
"document": (IMAGE_FILE, f, "image/jpeg")
}
try:
# Fire the multi-part form POST request
response = requests.post(URL, data=form_data, files=files)
print(f"Status Code: {response.status_code}\n")
if response.status_code == 200:
print("βœ… Adjudication Success Response:")
print(json.dumps(response.json(), indent=2))
else:
print("❌ Server Error Response:")
print(response.text)
except requests.exceptions.ConnectionError:
print("❌ Connection Error: Is your uvicorn server still running on port 8000?")
if __name__ == "__main__":
run_test()