Code cleanup

This commit is contained in:
Eric van Blokland
2021-09-28 17:25:37 +02:00
parent 9382eb2ff4
commit 55aab87f4e
6 changed files with 19 additions and 24 deletions

View File

@@ -6,6 +6,7 @@ from mopidy_radionet import backend
from mopidy_radionet.radionet import RadioNetClient
from mopidy_radionet.library import RadioNetLibraryProvider
@pytest.fixture
def backend_mock():
backend_mock = mock.Mock(spec=backend.RadioNetBackend)
@@ -15,10 +16,12 @@ def backend_mock():
backend_mock.radionet.set_favorites({'lush'})
return backend_mock
@pytest.fixture
def library(backend_mock):
return backend_mock.library
@pytest.fixture
def radionet(backend_mock):
return backend_mock.radionet

View File

@@ -1,13 +1,12 @@
from unittest import mock
def test_browse_root(library):
results = library.browse('radionet:root');
results = library.browse('radionet:root')
assert 8 == len(results)
def test_browse_localstations(library):
results = library.browse('radionet:localstations');
results = library.browse('radionet:localstations')
assert len(results) > 0
page_uri = results[0].uri if results is not None else None
@@ -19,12 +18,12 @@ def test_browse_localstations(library):
def test_browse_topstations(library):
results = library.browse('radionet:topstations');
results = library.browse('radionet:topstations')
assert len(results) > 0
def test_browse_genres(library):
results = library.browse('radionet:genres');
results = library.browse('radionet:genres')
assert len(results) > 0
cat_uri = results[0].uri if results is not None else None
@@ -47,7 +46,7 @@ def test_browse_genres(library):
def test_browse_topics(library):
results = library.browse('radionet:topics');
results = library.browse('radionet:topics')
assert len(results) > 0
cat_uri = results[0].uri if results is not None else None
@@ -71,7 +70,7 @@ def test_browse_topics(library):
def test_browse_languages(library):
results = library.browse('radionet:languages');
results = library.browse('radionet:languages')
assert len(results) > 0
cat_uri = results[5].uri if results is not None else None
@@ -95,7 +94,7 @@ def test_browse_languages(library):
def test_browse_cities(library):
results = library.browse('radionet:cities');
results = library.browse('radionet:cities')
assert len(results) > 0
cat_uri = results[0].uri if results is not None else None
@@ -119,7 +118,7 @@ def test_browse_cities(library):
def test_browse_countries(library):
results = library.browse('radionet:countries');
results = library.browse('radionet:countries')
assert len(results) > 0
cat_uri = results[0].uri if results is not None else None
@@ -143,11 +142,10 @@ def test_browse_countries(library):
def test_browse_favorites(library):
results = library.browse('radionet:favorites');
results = library.browse('radionet:favorites')
assert 1 == len(results)
def test_search(library):
result = library.search({'any': ['radio ram']})
@@ -161,7 +159,6 @@ def test_search(library):
def test_lookup(library):
results = library.browse('radionet:favorites')
assert 1 == len(results)
@@ -170,7 +167,6 @@ 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'

View File

@@ -1,8 +1,7 @@
from unittest import mock
def test_get_genres(radionet):
genres = radionet.get_genres();
genres = radionet.get_genres()
assert len(genres) > 0