Implemented playlist_deleted event
This commit is contained in:
parent
ee0f2f2a94
commit
8975e72b34
@ -36,6 +36,8 @@ Core API
|
||||
- Add `max_tracklist_length` config and limitation. (Fixes: :issue:`997`
|
||||
PR: :issue:`1225`)
|
||||
|
||||
- Added ``playlist_deleted`` event (Fixes: :issue:`996`)
|
||||
|
||||
Models
|
||||
------
|
||||
|
||||
|
||||
@ -123,6 +123,17 @@ class CoreListener(listener.Listener):
|
||||
"""
|
||||
pass
|
||||
|
||||
def playlist_deleted(self, uri):
|
||||
"""
|
||||
Called whenever a playlist is deleted.
|
||||
|
||||
*MAY* be implemented by actor.
|
||||
|
||||
:param uri: the uri of the deleted playlist
|
||||
:type uri: string
|
||||
"""
|
||||
pass
|
||||
|
||||
def options_changed(self):
|
||||
"""
|
||||
Called whenever an option is changed.
|
||||
|
||||
@ -178,11 +178,12 @@ class PlaylistsController(object):
|
||||
uri_scheme = urlparse.urlparse(uri).scheme
|
||||
backend = self.backends.with_playlists.get(uri_scheme, None)
|
||||
if not backend:
|
||||
return
|
||||
return None # TODO: error reporting to user
|
||||
|
||||
with _backend_error_handling(backend):
|
||||
backend.playlists.delete(uri).get()
|
||||
# TODO: emit playlist changed?
|
||||
# TODO: error detection and reporting to user
|
||||
listener.CoreListener.send('playlist_deleted', uri=uri)
|
||||
|
||||
# TODO: return value?
|
||||
|
||||
|
||||
@ -54,6 +54,7 @@ class M3UPlaylistsProvider(backend.PlaylistsProvider):
|
||||
logger.warning(
|
||||
'Trying to delete missing playlist file %s', path)
|
||||
del self._playlists[uri]
|
||||
logger.info('Deleted playlist %s', uri)
|
||||
else:
|
||||
logger.warning('Trying to delete unknown playlist %s', uri)
|
||||
|
||||
|
||||
@ -99,10 +99,11 @@ class BackendEventsTest(unittest.TestCase):
|
||||
|
||||
self.assertEqual(send.call_args[0][0], 'playlist_changed')
|
||||
|
||||
@unittest.SkipTest
|
||||
def test_playlists_delete_sends_playlist_deleted_event(self, send):
|
||||
# TODO We should probably add a playlist_deleted event
|
||||
pass
|
||||
playlist = self.core.playlists.create('foo').get()
|
||||
self.core.playlists.delete(playlist.uri).get()
|
||||
|
||||
self.assertEqual(send.call_args[0][0], 'playlist_deleted')
|
||||
|
||||
def test_playlists_save_sends_playlist_changed_event(self, send):
|
||||
playlist = self.core.playlists.create('foo').get()
|
||||
|
||||
@ -47,6 +47,9 @@ class CoreListenerTest(unittest.TestCase):
|
||||
def test_listener_has_default_impl_for_playlist_changed(self):
|
||||
self.listener.playlist_changed(Playlist())
|
||||
|
||||
def test_listener_has_default_impl_for_playlist_deleted(self):
|
||||
self.listener.playlist_deleted(Playlist())
|
||||
|
||||
def test_listener_has_default_impl_for_options_changed(self):
|
||||
self.listener.options_changed()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user