history: Change size property to get_length() method
For consistency with tracklist.get_length() and our goal of aligning Python and JS APIs by using less properties in the core API.
This commit is contained in:
parent
5a67339855
commit
5317834baf
@ -37,8 +37,7 @@ class HistoryController(object):
|
||||
|
||||
self._history.insert(0, (timestamp, ref))
|
||||
|
||||
@property
|
||||
def size(self):
|
||||
def get_length(self):
|
||||
"""Get the number of tracks in the history.
|
||||
|
||||
:returns: the history length
|
||||
|
||||
@ -19,15 +19,19 @@ class PlaybackHistoryTest(unittest.TestCase):
|
||||
|
||||
def test_add_track(self):
|
||||
self.history.add(self.tracks[0])
|
||||
self.assertEqual(self.history.get_length(), 1)
|
||||
|
||||
self.history.add(self.tracks[1])
|
||||
self.assertEqual(self.history.get_length(), 2)
|
||||
|
||||
self.history.add(self.tracks[2])
|
||||
self.assertEqual(self.history.size, 3)
|
||||
self.assertEqual(self.history.get_length(), 3)
|
||||
|
||||
def test_non_tracks_are_rejected(self):
|
||||
with self.assertRaises(TypeError):
|
||||
self.history.add(object())
|
||||
|
||||
self.assertEqual(self.history.size, 0)
|
||||
self.assertEqual(self.history.get_length(), 0)
|
||||
|
||||
def test_history_entry_contents(self):
|
||||
track = self.tracks[0]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user