Fixed regression in search

This commit is contained in:
Eric van Blokland
2021-09-08 18:20:12 +02:00
parent 63da37c012
commit 76161adfdb
3 changed files with 16 additions and 4 deletions

View File

@@ -209,9 +209,7 @@ class RadioNetLibraryProvider(backend.LibraryProvider):
result = []
self.backend.radionet.do_search(" ".join(query["any"]))
for station in self.backend.radionet.search_results:
for station in self.backend.radionet.do_search(" ".join(query["any"])):
result.append(self.station_to_track(station))
return SearchResult(tracks=result)

View File

@@ -293,7 +293,7 @@ class RadioNetClient(object):
)
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"
url_params = {
@@ -308,6 +308,8 @@ class RadioNetClient(object):
logger.error("Radio.net: Search error " + response.text)
else:
logger.debug("Radio.net: Done search")
if search_results is None:
search_results = []
json = response.json()
for match in json["categories"][0]["matches"]:
station = self.get_station_by_id(match["id"])

View File

@@ -140,3 +140,15 @@ def test_browse_countries(library):
def test_browse_favorites(library):
results = library.browse('radionet:favorites');
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