Task Description: Implement a Simple Weather API Client
Develop a simple Weather API client in the /app/ directory that provides functionality to fetch weather data for a specified city.
Requirements:
Class Definition: Implement a class named WeatherClient.
Initialization: The constructor should accept an API key (String) and store it in an instance variable.
Fetch Weather Method: Implement a method named fetch_weather(city: str) -> dict that:
Takes a city name as input and makes an HTTP GET request to the weather API (use a placeholder URL: https://api.example.com/weather?city={city}&apikey={api_key}).
Uses the stored API key for authorization.
Returns the response as a dictionary containing at least the following keys: temperature, humidity, description.
Handle any HTTP errors gracefully and return an empty dictionary in case of a failed request.
Caching Mechanism: Implement a simple caching mechanism that:
Caches results for each city for 10 minutes.
Before making an API call, check if the weather data for the city exists in the cache and is still valid (i.e., created less than 10 minutes ago). If valid, return the cached data instead of making a new API call.
Error Handling: Ensure that if the city is not found or any error occurs during the API call, the method returns an appropriate error message as a dictionary:
python
{"error": "City not found"}
Follow Best Practices: Write tests for the behavior of the WeatherClient class, including:
Successful API calls returning the correct structure.
Handling of API errors and city not found case.
Caching behavior is working as expected.
Place your implementation in the /app/ directory and ensure it adheres to the described functionality to pass the provided test code.