import httpx import asyncio BASE_URL = "http://localhost:8000" ACCESS_KEY = "test" async def test_endpoints(): async with httpx.AsyncClient(timeout=30.0) as client: # Test Current print("Testing /current...") res = await client.get( f"{BASE_URL}/current?access_key={ACCESS_KEY}&query=New York" ) print(f"Status: {res.status_code}") if res.status_code == 200: print(f"Location: {res.json()['location']['name']}") print(f"Condition: {res.json()['current']['weather_descriptions'][0]}") # Test Forecast print("\nTesting /forecast...") res = await client.get( f"{BASE_URL}/forecast?access_key={ACCESS_KEY}&query=London&forecast_days=3" ) print(f"Status: {res.status_code}") if res.status_code == 200: print(f"Forecast dates: {list(res.json()['forecast'].keys())}") # Test Autocomplete print("\nTesting /autocomplete...") res = await client.get( f"{BASE_URL}/autocomplete?access_key={ACCESS_KEY}&query=San Fran" ) print(f"Status: {res.status_code}") if res.status_code == 200: print(f"Suggestions: {[loc['name'] for loc in res.json()['locations']]}") if __name__ == "__main__": asyncio.run(test_endpoints())