#!/usr/bin/env python3
"""
Test script to debug HTTP client connection to account service
"""

import asyncio
import sys
import os

# Add shared modules to path
sys.path.append('/app')

async def test_http_client():
    """Test HTTP client connection to account service"""
    try:
        from shared.http_client import http_client
        from shared.config import settings
        
        print(f"Testing connection to: {settings.account_service_url}")
        
        # Test basic connection
        response = await http_client.get(f"{settings.account_service_url}/health")
        print(f"Health check response: {response.status_code}")
        
        # Test with a dummy user ID
        test_user_id = "689f86446a45c98673b2fd70"
        response = await http_client.get(
            f"{settings.account_service_url}/accounts/me",
            headers={"Authorization": f"Bearer {test_user_id}"}
        )
        print(f"Account service response: {response.status_code}")
        
        if response.status_code == 200:
            data = await response.json()
            print(f"Response data: {data}")
        else:
            print(f"Error response: {await response.text()}")
            
    except Exception as e:
        print(f"Error: {e}")
        import traceback
        traceback.print_exc()

if __name__ == "__main__":
    asyncio.run(test_http_client())
