Rename tracks_len to length, and add test
This commit is contained in:
parent
449bb87b90
commit
c5a4bb0e22
@ -40,9 +40,9 @@ class CurrentPlaylistController(object):
|
||||
return [ct[1] for ct in self._cp_tracks]
|
||||
|
||||
@property
|
||||
def tracks_len(self):
|
||||
def length(self):
|
||||
"""
|
||||
Length of current playlist
|
||||
Length of the current playlist.
|
||||
"""
|
||||
return len(self._cp_tracks)
|
||||
|
||||
|
||||
@ -166,7 +166,7 @@ def status(context):
|
||||
decimal places for millisecond precision.
|
||||
"""
|
||||
futures = {
|
||||
'current_playlist.tracks_len': context.backend.current_playlist.tracks_len,
|
||||
'current_playlist.length': context.backend.current_playlist.length,
|
||||
'current_playlist.version': context.backend.current_playlist.version,
|
||||
'mixer.volume': context.mixer.volume,
|
||||
'playback.consume': context.backend.playback.consume,
|
||||
@ -213,7 +213,7 @@ def _status_consume(futures):
|
||||
return 0
|
||||
|
||||
def _status_playlist_length(futures):
|
||||
return futures['current_playlist.tracks_len'].get()
|
||||
return futures['current_playlist.length'].get()
|
||||
|
||||
def _status_playlist_version(futures):
|
||||
return futures['current_playlist.version'].get()
|
||||
|
||||
@ -18,6 +18,13 @@ class CurrentPlaylistControllerTest(object):
|
||||
|
||||
assert len(self.tracks) == 3, 'Need three tracks to run tests.'
|
||||
|
||||
def test_length(self):
|
||||
self.assertEqual(0, len(self.controller.cp_tracks))
|
||||
self.assertEqual(0, self.controller.length)
|
||||
self.controller.append(self.tracks)
|
||||
self.assertEqual(3, len(self.controller.cp_tracks))
|
||||
self.assertEqual(3, self.controller.length)
|
||||
|
||||
def test_add(self):
|
||||
for track in self.tracks:
|
||||
cp_track = self.controller.add(track)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user