Add destroy method to all backend pieces
This commit is contained in:
parent
ce2c032247
commit
eb538f46be
@ -41,6 +41,21 @@ class BaseBackend(object):
|
||||
#: List of URI prefixes this backend can handle.
|
||||
uri_handlers = []
|
||||
|
||||
def destroy(self):
|
||||
if self.current_playlist:
|
||||
self.current_playlist.destroy()
|
||||
|
||||
if self.library:
|
||||
self.library.destroy()
|
||||
|
||||
if self.mixer:
|
||||
self.mixer.destroy()
|
||||
|
||||
if self.playback:
|
||||
self.playback.destroy()
|
||||
|
||||
if self.stored_playlists:
|
||||
self.stored_playlists.destroy()
|
||||
|
||||
class BaseCurrentPlaylistController(object):
|
||||
"""
|
||||
@ -181,6 +196,9 @@ class BaseCurrentPlaylistController(object):
|
||||
random.shuffle(shuffled)
|
||||
self.playlist = self.playlist.with_(tracks=before+shuffled+after)
|
||||
|
||||
def destroy(self):
|
||||
pass
|
||||
|
||||
|
||||
class BaseLibraryController(object):
|
||||
"""
|
||||
@ -234,6 +252,9 @@ class BaseLibraryController(object):
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def destroy(self):
|
||||
pass
|
||||
|
||||
|
||||
class BasePlaybackController(object):
|
||||
"""
|
||||
@ -483,6 +504,9 @@ class BasePlaybackController(object):
|
||||
def _stop(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def destroy(self):
|
||||
pass
|
||||
|
||||
|
||||
class BaseStoredPlaylistsController(object):
|
||||
"""
|
||||
@ -594,3 +618,6 @@ class BaseStoredPlaylistsController(object):
|
||||
:rtype: list of :class:`mopidy.models.Playlist`
|
||||
"""
|
||||
return filter(lambda p: query in p.name, self._playlists)
|
||||
|
||||
def destroy(self):
|
||||
pass
|
||||
|
||||
@ -18,6 +18,9 @@ class BaseMixer(object):
|
||||
volume = 100
|
||||
self._set_volume(volume)
|
||||
|
||||
def destroy(self):
|
||||
pass
|
||||
|
||||
def _get_volume(self):
|
||||
"""
|
||||
Return volume as integer in range [0, 100]. :class:`None` if unknown.
|
||||
|
||||
@ -26,7 +26,7 @@ class BaseCurrentPlaylistControllerTest(object):
|
||||
assert len(self.tracks) >= 3, 'Need at least three tracks to run tests.'
|
||||
|
||||
def tearDown(self):
|
||||
self.backend.playback.destroy()
|
||||
self.backend.destroy()
|
||||
|
||||
def test_add(self):
|
||||
for track in self.tracks:
|
||||
@ -205,7 +205,7 @@ class BasePlaybackControllerTest(object):
|
||||
'First song needs to be at least 2000 miliseconds'
|
||||
|
||||
def tearDown(self):
|
||||
self.backend.playback.destroy()
|
||||
self.backend.destroy()
|
||||
|
||||
def test_initial_state_is_stopped(self):
|
||||
self.assertEqual(self.playback.state, self.playback.STOPPED)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user