#!/usr/bin/env python3
"""
Test script for the updated name and address verification API
"""

import requests
import json

# Test data with name fields
test_data = {
    "first_name": "John",
    "middle_name": "",
    "last_name": "Doe",
    "city": "Dummy City", 
    "state": "Toronto",
    "county": "Canada",
    "zip_code": "90001",
    "street_name": "Street 7",
    "house_number": "134"
}

def test_name_address_verification():
    """Test the name and address verification endpoint"""
    
    base_url = "http://localhost:8000"
    
    print("🔍 Testing Name and Address Verification API")
    print("=" * 50)
    
    # Test 1: Check if server is running
    try:
        response = requests.get(f"{base_url}/")
        print(f"✅ Server Status: {response.json()}")
    except requests.exceptions.ConnectionError:
        print("❌ Server is not running. Please start the server with: python src/main.py")
        return
    
    # Test 2: Check uploads directory
    try:
        response = requests.get(f"{base_url}/debug/uploads")
        print(f"📁 Uploads Directory: {response.json()}")
    except Exception as e:
        print(f"⚠️  Could not check uploads directory: {e}")
    
    # Test 3: Test data structure
    print(f"\n📋 Test Data:")
    print(json.dumps(test_data, indent=2))
    
    print(f"\n🧪 Required Fields Check:")
    required_fields = ["first_name", "last_name", "city", "state", "county", "zip_code", "street_name", "house_number"]
    for field in required_fields:
        if field in test_data:
            print(f"  ✅ {field}: {test_data[field]}")
        else:
            print(f"  ❌ {field}: Missing")
    
    print(f"\n📝 API Documentation:")
    print(f"  Endpoint: POST {base_url}/api/v1/prompt/verify-address")
    print(f"  Fields: address_json (form data) + file (multipart)")
    print(f"  
    Test with a document image containing:")
    print(f"    - Name: John Doe")
    print(f"    - Address: 134 Street 7, Dummy City, Toronto, Canada 90001")

if __name__ == "__main__":
    test_name_address_verification()