[meteofrance] allow to iter forecasts using town name in addition to city id
This commit is contained in:
parent
7b8bd6c661
commit
74d166037f
2 changed files with 12 additions and 1 deletions
|
|
@ -46,4 +46,12 @@ class MeteofranceModule(Module, CapWeather):
|
|||
return self.browser.iter_city_search(pattern)
|
||||
|
||||
def get_city(self, _id):
|
||||
return find_object(self.iter_city_search(_id), id=_id, error=CityNotFound)
|
||||
cities = list(self.iter_city_search(_id))
|
||||
|
||||
if len(cities) == 0:
|
||||
raise CityNotFound()
|
||||
|
||||
try:
|
||||
return find_object(cities, id=_id, error=CityNotFound)
|
||||
except CityNotFound:
|
||||
return cities[0]
|
||||
|
|
|
|||
|
|
@ -34,3 +34,6 @@ class MeteoFranceTest(BackendTest):
|
|||
|
||||
forecasts = list(self.backend.iter_forecast(city.id))
|
||||
self.assertTrue(len(forecasts) > 0)
|
||||
|
||||
forecast2 = list(self.backend.iter_forecast('blagnac'))
|
||||
self.assertTrue(len(forecast2) > 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue