Changes for V5 api compatibility
This commit is contained in:
@@ -12,7 +12,6 @@ def backend_mock():
|
||||
backend_mock = mock.Mock(spec=backend.RadioNetBackend)
|
||||
backend_mock.radionet = RadioNetClient(proxy_config=None)
|
||||
backend_mock.library = RadioNetLibraryProvider(backend=backend_mock)
|
||||
backend_mock.radionet.set_apikey('test')
|
||||
backend_mock.radionet.set_favorites({'lush'})
|
||||
return backend_mock
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
|
||||
|
||||
def test_browse_root(library):
|
||||
results = library.browse('radionet:root')
|
||||
assert 8 == len(results)
|
||||
assert 7 == len(results)
|
||||
|
||||
|
||||
def test_browse_localstations(library):
|
||||
results = library.browse('radionet:localstations')
|
||||
results = library.browse('radionet:local')
|
||||
assert len(results) > 0
|
||||
|
||||
page_uri = results[0].uri if results is not None else None
|
||||
@@ -17,28 +15,23 @@ def test_browse_localstations(library):
|
||||
# assert len(results) > 0
|
||||
|
||||
|
||||
def test_browse_topstations(library):
|
||||
results = library.browse('radionet:topstations')
|
||||
assert len(results) > 0
|
||||
|
||||
|
||||
def test_browse_genres(library):
|
||||
results = library.browse('radionet:genres')
|
||||
assert len(results) > 0
|
||||
genres = library.browse('radionet:genres')
|
||||
assert len(genres) > 0
|
||||
|
||||
cat_uri = results[0].uri if results is not None else None
|
||||
cat_uri = genres[0].uri if genres is not None else None
|
||||
assert cat_uri is not None
|
||||
|
||||
results = library.browse(cat_uri)
|
||||
assert len(results) == 2
|
||||
pages = library.browse(cat_uri)
|
||||
assert len(pages) == 7
|
||||
|
||||
sort_uri = results[0].uri if results is not None else None
|
||||
assert sort_uri is not None
|
||||
page_uri = pages[0].uri if pages is not None else None
|
||||
assert page_uri is not None
|
||||
|
||||
results = library.browse(sort_uri)
|
||||
results = library.browse(page_uri)
|
||||
assert len(results) > 0
|
||||
|
||||
page_uri = results[0].uri if results is not None else None
|
||||
page_uri = pages[len(pages) - 1].uri if results is not None else None
|
||||
assert page_uri is not None
|
||||
|
||||
results = library.browse(page_uri)
|
||||
@@ -47,19 +40,13 @@ def test_browse_genres(library):
|
||||
|
||||
def test_browse_topics(library):
|
||||
results = library.browse('radionet:topics')
|
||||
assert len(results) > 0
|
||||
assert len(results) > 2
|
||||
|
||||
cat_uri = results[0].uri if results is not None else None
|
||||
cat_uri = results[2].uri if results is not None else None
|
||||
assert cat_uri is not None
|
||||
|
||||
results = library.browse(cat_uri)
|
||||
assert len(results) == 2
|
||||
|
||||
sort_uri = results[0].uri if results is not None else None
|
||||
assert sort_uri is not None
|
||||
|
||||
results = library.browse(sort_uri)
|
||||
assert len(results) > 0
|
||||
assert len(results) > 2
|
||||
|
||||
page_uri = results[0].uri if results is not None else None
|
||||
assert page_uri is not None
|
||||
@@ -77,13 +64,7 @@ def test_browse_languages(library):
|
||||
assert cat_uri is not None
|
||||
|
||||
results = library.browse(cat_uri)
|
||||
assert len(results) == 2
|
||||
|
||||
sort_uri = results[0].uri if results is not None else None
|
||||
assert sort_uri is not None
|
||||
|
||||
results = library.browse(sort_uri)
|
||||
assert len(results) > 0
|
||||
assert len(results) == 11
|
||||
|
||||
page_uri = results[0].uri if results is not None else None
|
||||
assert page_uri is not None
|
||||
@@ -103,12 +84,6 @@ def test_browse_cities(library):
|
||||
results = library.browse(cat_uri)
|
||||
assert len(results) == 2
|
||||
|
||||
sort_uri = results[0].uri if results is not None else None
|
||||
assert sort_uri is not None
|
||||
|
||||
results = library.browse(sort_uri)
|
||||
assert len(results) > 0
|
||||
|
||||
page_uri = results[0].uri if results is not None else None
|
||||
assert page_uri is not None
|
||||
|
||||
@@ -125,13 +100,7 @@ def test_browse_countries(library):
|
||||
assert cat_uri is not None
|
||||
|
||||
results = library.browse(cat_uri)
|
||||
assert len(results) == 2
|
||||
|
||||
sort_uri = results[0].uri if results is not None else None
|
||||
assert sort_uri is not None
|
||||
|
||||
results = library.browse(sort_uri)
|
||||
assert len(results) > 0
|
||||
assert len(results) == 4
|
||||
|
||||
page_uri = results[0].uri if results is not None else None
|
||||
assert page_uri is not None
|
||||
@@ -147,13 +116,13 @@ def test_browse_favorites(library):
|
||||
|
||||
|
||||
def test_search(library):
|
||||
result = library.search({'any': ['radio ram']})
|
||||
result = library.search({'any': ['katze']})
|
||||
|
||||
assert len(result.tracks) > 0
|
||||
|
||||
old_length = len(result.tracks)
|
||||
|
||||
result = library.search({'any': ['radio ram']})
|
||||
result = library.search({'any': ['katze']})
|
||||
|
||||
assert len(result.tracks) == old_length
|
||||
|
||||
@@ -169,4 +138,4 @@ def test_lookup(library):
|
||||
def test_track_by_slug(library):
|
||||
results = library.lookup('radionet:track:dancefm')
|
||||
assert 1 == len(results)
|
||||
assert results[0].uri == 'radionet:track:2180'
|
||||
assert results[0].uri == 'radionet:track:dancefm'
|
||||
|
||||
@@ -4,39 +4,33 @@ def test_get_genres(radionet):
|
||||
genres = radionet.get_genres()
|
||||
assert len(genres) > 0
|
||||
|
||||
|
||||
def test_get_top_stations(radionet):
|
||||
result = radionet.get_category('topstations', 1)
|
||||
assert len(result) > 0
|
||||
|
||||
|
||||
def test_get_local_stations(radionet):
|
||||
result = radionet.get_category('localstations', 1)
|
||||
result = radionet.get_simple_category('local', 1)
|
||||
assert len(result) > 0
|
||||
|
||||
|
||||
def test_do_search(radionet):
|
||||
result = radionet.do_search("radio ram")
|
||||
result = radionet.do_search("\"radio ram\"")
|
||||
assert len(result) > 0
|
||||
|
||||
assert result[0].stream_url is None
|
||||
assert result[0].stream_url is not None
|
||||
|
||||
assert radionet.get_stream_url(result[0].id) is not None
|
||||
|
||||
|
||||
def test_get_favorites(radionet):
|
||||
radionet.cache = {};
|
||||
test_favorites = ["Rock Antenne", "radio ram", "eska", "dancefm"]
|
||||
radionet.cache = {}
|
||||
test_favorites = ["rockantenne", "eska", "dancefm"]
|
||||
radionet.set_favorites(test_favorites)
|
||||
result = radionet.get_favorites()
|
||||
assert len(result) == len(test_favorites)
|
||||
|
||||
assert result[2].name == 'Eska'
|
||||
assert result[1].name == 'Eska'
|
||||
|
||||
|
||||
def test_favorites_broken_slug(radionet):
|
||||
radionet.cache = {};
|
||||
test_favorites = ["radio357"]
|
||||
radionet.cache = {}
|
||||
test_favorites = ["radio 357"]
|
||||
radionet.set_favorites(test_favorites)
|
||||
result = radionet.get_favorites()
|
||||
assert len(result) == 0
|
||||
assert len(result) == 1
|
||||
|
||||
Reference in New Issue
Block a user