Fixed regression in search
This commit is contained in:
@@ -209,9 +209,7 @@ class RadioNetLibraryProvider(backend.LibraryProvider):
|
|||||||
|
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
self.backend.radionet.do_search(" ".join(query["any"]))
|
for station in self.backend.radionet.do_search(" ".join(query["any"])):
|
||||||
|
|
||||||
for station in self.backend.radionet.search_results:
|
|
||||||
result.append(self.station_to_track(station))
|
result.append(self.station_to_track(station))
|
||||||
|
|
||||||
return SearchResult(tracks=result)
|
return SearchResult(tracks=result)
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ class RadioNetClient(object):
|
|||||||
)
|
)
|
||||||
return self.set_cache(cache_key, favorite_stations, 1440)
|
return self.set_cache(cache_key, favorite_stations, 1440)
|
||||||
|
|
||||||
def do_search(self, query_string, page_index=1, search_results=[]):
|
def do_search(self, query_string, page_index=1, search_results=None):
|
||||||
|
|
||||||
api_suffix = "/search/stationsonly"
|
api_suffix = "/search/stationsonly"
|
||||||
url_params = {
|
url_params = {
|
||||||
@@ -308,6 +308,8 @@ class RadioNetClient(object):
|
|||||||
logger.error("Radio.net: Search error " + response.text)
|
logger.error("Radio.net: Search error " + response.text)
|
||||||
else:
|
else:
|
||||||
logger.debug("Radio.net: Done search")
|
logger.debug("Radio.net: Done search")
|
||||||
|
if search_results is None:
|
||||||
|
search_results = []
|
||||||
json = response.json()
|
json = response.json()
|
||||||
for match in json["categories"][0]["matches"]:
|
for match in json["categories"][0]["matches"]:
|
||||||
station = self.get_station_by_id(match["id"])
|
station = self.get_station_by_id(match["id"])
|
||||||
|
|||||||
@@ -140,3 +140,15 @@ def test_browse_countries(library):
|
|||||||
def test_browse_favorites(library):
|
def test_browse_favorites(library):
|
||||||
results = library.browse('radionet:favorites');
|
results = library.browse('radionet:favorites');
|
||||||
assert 1 == len(results)
|
assert 1 == len(results)
|
||||||
|
|
||||||
|
|
||||||
|
def test_search(library):
|
||||||
|
result = library.search({'any': ['radio ram']})
|
||||||
|
|
||||||
|
assert len(result.tracks) > 0
|
||||||
|
|
||||||
|
old_length = len(result.tracks)
|
||||||
|
|
||||||
|
result = library.search({'any': ['radio ram']})
|
||||||
|
|
||||||
|
assert len(result.tracks) == old_length
|
||||||
Reference in New Issue
Block a user