Skip to main content
Glama
ImDPS
by ImDPS
test_weather_api.py1.51 kB
#!/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())

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ImDPS/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server