backend: Rename library.name to library.root_directory_name

This commit is contained in:
Stein Magnus Jodal 2014-01-03 23:07:31 +01:00
parent af3b0e40fd
commit 69836d2e16
4 changed files with 9 additions and 11 deletions

View File

@ -50,11 +50,9 @@ class BaseLibraryProvider(object):
pykka_traversable = True
name = None
root_directory_name = None
"""
Name of the library.
Used as the library directory name in Mopidy's virtual file system.
Name of the library's root directory in Mopidy's virtual file system.
*MUST be set by any class that implements :meth:`browse`.*
"""
@ -66,7 +64,8 @@ class BaseLibraryProvider(object):
"""
See :meth:`mopidy.core.LibraryController.browse`.
If you implement this method, make sure to also set :attr:`name`.
If you implement this method, make sure to also set
:attr:`root_directory_name`.
*MAY be implemented by subclass.*
"""

View File

@ -38,7 +38,7 @@ class DummyBackend(pykka.ThreadingActor, base.Backend):
class DummyLibraryProvider(base.BaseLibraryProvider):
name = 'dummy'
root_directory_name = 'dummy'
def __init__(self, *args, **kwargs):
super(DummyLibraryProvider, self).__init__(*args, **kwargs)

View File

@ -65,7 +65,7 @@ class LibraryController(object):
return []
backends = {
backend.library.name.get(): backend
backend.library.root_directory_name.get(): backend
for backend in self.backends.with_library.values()
if backend.library.browse('/').get()}

View File

@ -13,13 +13,13 @@ class CoreLibraryTest(unittest.TestCase):
self.backend1 = mock.Mock()
self.backend1.uri_schemes.get.return_value = ['dummy1']
self.library1 = mock.Mock(spec=base.BaseLibraryProvider)
self.library1.name.get.return_value = 'dummy1'
self.library1.root_directory_name.get.return_value = 'dummy1'
self.backend1.library = self.library1
self.backend2 = mock.Mock()
self.backend2.uri_schemes.get.return_value = ['dummy2']
self.library2 = mock.Mock(spec=base.BaseLibraryProvider)
self.library2.name.get.return_value = 'dummy2'
self.library2.root_directory_name.get.return_value = 'dummy2'
self.backend2.library = self.library2
# A backend without the optional library provider
@ -89,11 +89,10 @@ class CoreLibraryTest(unittest.TestCase):
self.assertEqual(self.library2.browse.call_count, 1)
def test_browse_dir_returns_subdirs_and_tracks(self):
result1 = [
self.library1.browse().get.return_value = [
Ref(uri='/foo/bar', name='bar', type=Ref.DIRECTORY),
Ref(uri='dummy1:/foo/baz.mp3', name='Baz', type=Ref.TRACK),
]
self.library1.browse().get.return_value = result1
self.library1.browse.reset_mock()
result = self.core.library.browse('/dummy1/foo')