Fixed error caused by unrecognized favorite not yielding result in search
This commit is contained in:
@@ -370,10 +370,15 @@ class RadioNetClient(object):
|
|||||||
logger.debug("Radio.net: Done search")
|
logger.debug("Radio.net: Done search")
|
||||||
json = response.json()
|
json = response.json()
|
||||||
|
|
||||||
# take only the first match!
|
number_pages = int(json["numberPages"])
|
||||||
station = self._get_station_from_search_result(
|
logger.error(json)
|
||||||
json["categories"][0]["matches"][0]
|
if number_pages != 0:
|
||||||
)
|
# take only the first match!
|
||||||
|
station = self._get_station_from_search_result(
|
||||||
|
json["categories"][0]["matches"][0]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.warning("Radio.net: No results for %s", station_slug)
|
||||||
|
|
||||||
if station and station.playable:
|
if station and station.playable:
|
||||||
favorite_stations.append(station)
|
favorite_stations.append(station)
|
||||||
|
|||||||
@@ -26,9 +26,16 @@ def test_do_search(radionet):
|
|||||||
|
|
||||||
|
|
||||||
def test_get_favorites(radionet):
|
def test_get_favorites(radionet):
|
||||||
test_favorites = ("Rock Antenne", "radio ram", "eska", "dancefm")
|
test_favorites = ["Rock Antenne", "radio ram", "eska", "dancefm"]
|
||||||
radionet.set_favorites(test_favorites)
|
radionet.set_favorites(test_favorites)
|
||||||
result = radionet.get_favorites()
|
result = radionet.get_favorites()
|
||||||
assert len(result) == len(test_favorites)
|
assert len(result) == len(test_favorites)
|
||||||
|
|
||||||
assert result[2].name == 'Eska'
|
assert result[2].name == 'Eska'
|
||||||
|
|
||||||
|
|
||||||
|
def test_favorites_broken_slug(radionet):
|
||||||
|
test_favorites = ["radio357"]
|
||||||
|
radionet.set_favorites(test_favorites)
|
||||||
|
result = radionet.get_favorites()
|
||||||
|
assert len(result) == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user