fix cities search when there is only one result

This commit is contained in:
Romain Bignon 2012-10-27 10:35:54 +02:00
commit cc2ff8ff22
2 changed files with 3 additions and 1 deletions

View file

@ -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):

View file

@ -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)