#!/usr/bin/env python3
"""
Test script for the enhanced weather tool with Open-Meteo API integration.
"""
import asyncio
import sys
import os
# Add the src directory to the path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
from tools.weather import WeatherTool
async def test_weather_tool():
"""Test the weather tool with various locations."""
weather_tool = WeatherTool()
test_locations = [
"New York",
"London",
"Tokyo",
"Sydney",
"San Francisco",
"Los Angeles",
"Chicago",
"Miami"
]
print("🌤️ Testing Enhanced Weather Tool with Open-Meteo API")
print("=" * 60)
for location in test_locations:
print(f"\n📍 Testing location: {location}")
try:
result = await weather_tool.get_weather(location)
print(result)
except Exception as e:
print(f"❌ Error: {e}")
# Small delay between requests to be respectful to the API
await asyncio.sleep(1)
# Test error handling
print(f"\n📍 Testing error handling with invalid location: 'InvalidCity123'")
try:
result = await weather_tool.get_weather("InvalidCity123")
print(result)
except Exception as e:
print(f"❌ Error: {e}")
# Close the session
await weather_tool.close()
print("\n✅ Weather tool test completed!")
if __name__ == "__main__":
asyncio.run(test_weather_tool())