Make core.stored_playlists.playlists read-only (#217)
This commit is contained in:
parent
a679a47212
commit
0ddbb4e28a
@ -56,6 +56,13 @@ backends:
|
|||||||
dummy/mocked lower layers easier than with the old variant, where
|
dummy/mocked lower layers easier than with the old variant, where
|
||||||
dependencies where looked up in Pykka's actor registry.
|
dependencies where looked up in Pykka's actor registry.
|
||||||
|
|
||||||
|
- The stored playlists part of the core API have been revised a bit:
|
||||||
|
|
||||||
|
- :attr:`mopidy.core.StoredPlaylistsController.playlists` no longer supports
|
||||||
|
assignment to it. The `playlists` property on the backend layer still does,
|
||||||
|
and all functionality is maintained by assigning to the playlists
|
||||||
|
collections at the backend level.
|
||||||
|
|
||||||
**Changes**
|
**Changes**
|
||||||
|
|
||||||
- Made the :mod:`NAD mixer <mopidy.audio.mixers.nad>` responsive to interrupts
|
- Made the :mod:`NAD mixer <mopidy.audio.mixers.nad>` responsive to interrupts
|
||||||
|
|||||||
@ -15,17 +15,12 @@ class StoredPlaylistsController(object):
|
|||||||
"""
|
"""
|
||||||
Currently stored playlists.
|
Currently stored playlists.
|
||||||
|
|
||||||
Read/write. List of :class:`mopidy.models.Playlist`.
|
Read-only. List of :class:`mopidy.models.Playlist`.
|
||||||
"""
|
"""
|
||||||
futures = [b.stored_playlists.playlists for b in self.backends]
|
futures = [b.stored_playlists.playlists for b in self.backends]
|
||||||
results = pykka.get_all(futures)
|
results = pykka.get_all(futures)
|
||||||
return list(itertools.chain(*results))
|
return list(itertools.chain(*results))
|
||||||
|
|
||||||
@playlists.setter # noqa
|
|
||||||
def playlists(self, playlists):
|
|
||||||
# TODO Support multiple backends
|
|
||||||
self.backends[0].stored_playlists.playlists = playlists
|
|
||||||
|
|
||||||
def create(self, name):
|
def create(self, name):
|
||||||
"""
|
"""
|
||||||
Create a new playlist.
|
Create a new playlist.
|
||||||
|
|||||||
@ -65,12 +65,13 @@ class StoredPlaylistsControllerTest(object):
|
|||||||
|
|
||||||
def test_get_by_name_returns_unique_match(self):
|
def test_get_by_name_returns_unique_match(self):
|
||||||
playlist = Playlist(name='b')
|
playlist = Playlist(name='b')
|
||||||
self.stored.playlists = [Playlist(name='a'), playlist]
|
self.backend.stored_playlists.playlists = [
|
||||||
|
Playlist(name='a'), playlist]
|
||||||
self.assertEqual(playlist, self.stored.get(name='b'))
|
self.assertEqual(playlist, self.stored.get(name='b'))
|
||||||
|
|
||||||
def test_get_by_name_returns_first_of_multiple_matches(self):
|
def test_get_by_name_returns_first_of_multiple_matches(self):
|
||||||
playlist = Playlist(name='b')
|
playlist = Playlist(name='b')
|
||||||
self.stored.playlists = [
|
self.backend.stored_playlists.playlists = [
|
||||||
playlist, Playlist(name='a'), Playlist(name='b')]
|
playlist, Playlist(name='a'), Playlist(name='b')]
|
||||||
try:
|
try:
|
||||||
self.stored.get(name='b')
|
self.stored.get(name='b')
|
||||||
@ -79,7 +80,8 @@ class StoredPlaylistsControllerTest(object):
|
|||||||
self.assertEqual(u'"name=b" match multiple playlists', e[0])
|
self.assertEqual(u'"name=b" match multiple playlists', e[0])
|
||||||
|
|
||||||
def test_get_by_name_raises_keyerror_if_no_match(self):
|
def test_get_by_name_raises_keyerror_if_no_match(self):
|
||||||
self.stored.playlists = [Playlist(name='a'), Playlist(name='b')]
|
self.backend.stored_playlists.playlists = [
|
||||||
|
Playlist(name='a'), Playlist(name='b')]
|
||||||
try:
|
try:
|
||||||
self.stored.get(name='c')
|
self.stored.get(name='c')
|
||||||
self.fail(u'Should raise LookupError if no match')
|
self.fail(u'Should raise LookupError if no match')
|
||||||
|
|||||||
@ -7,7 +7,7 @@ from tests.frontends.mpd import protocol
|
|||||||
|
|
||||||
class StoredPlaylistsHandlerTest(protocol.BaseTestCase):
|
class StoredPlaylistsHandlerTest(protocol.BaseTestCase):
|
||||||
def test_listplaylist(self):
|
def test_listplaylist(self):
|
||||||
self.core.stored_playlists.playlists = [
|
self.backend.stored_playlists.playlists = [
|
||||||
Playlist(name='name', tracks=[Track(uri='file:///dev/urandom')])]
|
Playlist(name='name', tracks=[Track(uri='file:///dev/urandom')])]
|
||||||
|
|
||||||
self.sendRequest(u'listplaylist "name"')
|
self.sendRequest(u'listplaylist "name"')
|
||||||
@ -19,7 +19,7 @@ class StoredPlaylistsHandlerTest(protocol.BaseTestCase):
|
|||||||
self.assertEqualResponse(u'ACK [50@0] {listplaylist} No such playlist')
|
self.assertEqualResponse(u'ACK [50@0] {listplaylist} No such playlist')
|
||||||
|
|
||||||
def test_listplaylistinfo(self):
|
def test_listplaylistinfo(self):
|
||||||
self.core.stored_playlists.playlists = [
|
self.backend.stored_playlists.playlists = [
|
||||||
Playlist(name='name', tracks=[Track(uri='file:///dev/urandom')])]
|
Playlist(name='name', tracks=[Track(uri='file:///dev/urandom')])]
|
||||||
|
|
||||||
self.sendRequest(u'listplaylistinfo "name"')
|
self.sendRequest(u'listplaylistinfo "name"')
|
||||||
@ -35,7 +35,7 @@ class StoredPlaylistsHandlerTest(protocol.BaseTestCase):
|
|||||||
|
|
||||||
def test_listplaylists(self):
|
def test_listplaylists(self):
|
||||||
last_modified = datetime.datetime(2001, 3, 17, 13, 41, 17, 12345)
|
last_modified = datetime.datetime(2001, 3, 17, 13, 41, 17, 12345)
|
||||||
self.core.stored_playlists.playlists = [
|
self.backend.stored_playlists.playlists = [
|
||||||
Playlist(name='a', last_modified=last_modified)]
|
Playlist(name='a', last_modified=last_modified)]
|
||||||
|
|
||||||
self.sendRequest(u'listplaylists')
|
self.sendRequest(u'listplaylists')
|
||||||
@ -47,7 +47,7 @@ class StoredPlaylistsHandlerTest(protocol.BaseTestCase):
|
|||||||
def test_load_known_playlist_appends_to_current_playlist(self):
|
def test_load_known_playlist_appends_to_current_playlist(self):
|
||||||
self.core.current_playlist.append([Track(uri='a'), Track(uri='b')])
|
self.core.current_playlist.append([Track(uri='a'), Track(uri='b')])
|
||||||
self.assertEqual(len(self.core.current_playlist.tracks.get()), 2)
|
self.assertEqual(len(self.core.current_playlist.tracks.get()), 2)
|
||||||
self.core.stored_playlists.playlists = [
|
self.backend.stored_playlists.playlists = [
|
||||||
Playlist(name='A-list', tracks=[
|
Playlist(name='A-list', tracks=[
|
||||||
Track(uri='c'), Track(uri='d'), Track(uri='e')])]
|
Track(uri='c'), Track(uri='d'), Track(uri='e')])]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user