tests for browsing

This commit is contained in:
Marvin Steadfast 2016-11-28 16:11:24 +01:00
parent 7235d2341c
commit 5a7ab4f236
2 changed files with 27 additions and 0 deletions

View File

@ -1,3 +1,5 @@
import mock
import pytest
import mopidy_emby
@ -27,3 +29,19 @@ def emby_client(config, mocker):
mocker.patch('mopidy_emby.backend.EmbyHandler._password_data')
return mopidy_emby.backend.EmbyHandler(config)
@pytest.fixture
def backend_mock():
backend_mock = mock.Mock(autospec=mopidy_emby.backend.EmbyBackend)
backend_mock.remote(autospec=mopidy_emby.backend.EmbyHandler)
backend_mock.remote.get_artists.return_value = ['Artistlist']
backend_mock.remote.get_albums.return_value = ['Albumlist']
backend_mock.remote.get_tracks.return_value = ['Tracklist']
return backend_mock
@pytest.fixture
def provider(backend_mock):
return mopidy_emby.backend.EmbyLibraryProvider(backend_mock)

View File

@ -206,3 +206,12 @@ def test_create_artists(data, expected, emby_client):
track = json.load(f)
assert emby_client.create_artists(track) == expected
@pytest.mark.parametrize('uri,expected', [
('emby:', ['Artistlist']),
('emby:artist:123', ['Albumlist']),
('emby:album:123', ['Tracklist']),
])
def test_browse(uri, expected, provider):
assert provider.browse(uri) == expected