From cc2ff8ff227797b08261d3d3f0d0ea7d9372d48b Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sat, 27 Oct 2012 10:35:54 +0200 Subject: [PATCH] fix cities search when there is only one result --- modules/weather/browser.py | 2 ++ modules/weather/test.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/weather/browser.py b/modules/weather/browser.py index 2fcd0027..62941370 100644 --- a/modules/weather/browser.py +++ b/modules/weather/browser.py @@ -35,12 +35,14 @@ class WeatherBrowser(BaseBrowser): SEARCH_URL = 'http://www.weather.com/search/enhancedlocalsearch?where=%s' WEATHER_URL = 'http://www.weather.com/weather/today/%s' FORECAST_URL = 'http://www.weather.com/weather/tenday/%s' + RIGHTNOW_URL = 'http://www.weather.com/weather/right-now/%s' USER_AGENT = BaseBrowser.USER_AGENTS['desktop_firefox'] PAGES = { (SEARCH_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): CityPage, (WEATHER_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): WeatherPage, (FORECAST_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): ForecastPage, + (RIGHTNOW_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): WeatherPage, } def iter_city_search(self, pattern): diff --git a/modules/weather/test.py b/modules/weather/test.py index aec88bcb..bd2aa69b 100644 --- a/modules/weather/test.py +++ b/modules/weather/test.py @@ -29,7 +29,7 @@ class WeatherTest(BackendTest): self.assertTrue(len(list(paris)) == 0) paris = self.backend.iter_city_search('paris') - self.assertTrue(len(list(paris)) > 1) + self.assertTrue(len(list(paris)) >= 1) paris = self.backend.iter_city_search('paris france') self.assertTrue(len(list(paris)) == 1)