fix cities search when there is only one result
This commit is contained in:
parent
ad99fef5c2
commit
cc2ff8ff22
2 changed files with 3 additions and 1 deletions
|
|
@ -35,12 +35,14 @@ class WeatherBrowser(BaseBrowser):
|
||||||
SEARCH_URL = 'http://www.weather.com/search/enhancedlocalsearch?where=%s'
|
SEARCH_URL = 'http://www.weather.com/search/enhancedlocalsearch?where=%s'
|
||||||
WEATHER_URL = 'http://www.weather.com/weather/today/%s'
|
WEATHER_URL = 'http://www.weather.com/weather/today/%s'
|
||||||
FORECAST_URL = 'http://www.weather.com/weather/tenday/%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']
|
USER_AGENT = BaseBrowser.USER_AGENTS['desktop_firefox']
|
||||||
|
|
||||||
PAGES = {
|
PAGES = {
|
||||||
(SEARCH_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): CityPage,
|
(SEARCH_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): CityPage,
|
||||||
(WEATHER_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): WeatherPage,
|
(WEATHER_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): WeatherPage,
|
||||||
(FORECAST_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): ForecastPage,
|
(FORECAST_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): ForecastPage,
|
||||||
|
(RIGHTNOW_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): WeatherPage,
|
||||||
}
|
}
|
||||||
|
|
||||||
def iter_city_search(self, pattern):
|
def iter_city_search(self, pattern):
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class WeatherTest(BackendTest):
|
||||||
self.assertTrue(len(list(paris)) == 0)
|
self.assertTrue(len(list(paris)) == 0)
|
||||||
|
|
||||||
paris = self.backend.iter_city_search('paris')
|
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')
|
paris = self.backend.iter_city_search('paris france')
|
||||||
self.assertTrue(len(list(paris)) == 1)
|
self.assertTrue(len(list(paris)) == 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue