Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Make history.add() private #1063

Merged
merged 1 commit into from Mar 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/changelog.rst
Expand Up @@ -26,7 +26,8 @@ v1.0.0 (UNRELEASED)
the Python API with the WebSocket/JavaScript API. (Fixes: :issue:`952`)

- Add :class:`mopidy.core.HistoryController` which keeps track of what tracks
have been played. (Fixes: :issue:`423`, PR: :issue:`803`)
have been played. (Fixes: :issue:`423`, :issue:`1056`, PR: :issue:`803`,
:issue:`1063`)

- Add :class:`mopidy.core.MixerController` which keeps track of volume and
mute. (Fixes: :issue:`962`)
Expand Down
4 changes: 3 additions & 1 deletion mopidy/core/history.py
Expand Up @@ -15,9 +15,11 @@ class HistoryController(object):
def __init__(self):
self._history = []

def add(self, track):
def _add_track(self, track):
"""Add track to the playback history.

Internal method for :class:`mopidy.core.PlaybackController`.

:param track: track to add
:type track: :class:`mopidy.models.Track`
"""
Expand Down
2 changes: 1 addition & 1 deletion mopidy/core/playback.py
Expand Up @@ -312,7 +312,7 @@ def play(self, tl_track=None, on_error_step=1):

if success:
self.core.tracklist._mark_playing(tl_track)
self.core.history.add(tl_track.track)
self.core.history._add_track(tl_track.track)
# TODO: replace with stream-changed
self._trigger_track_playback_started()
else:
Expand Down
10 changes: 5 additions & 5 deletions tests/core/test_history.py
Expand Up @@ -18,24 +18,24 @@ def setUp(self): # noqa: N802
self.history = HistoryController()

def test_add_track(self):
self.history.add(self.tracks[0])
self.history._add_track(self.tracks[0])
self.assertEqual(self.history.get_length(), 1)

self.history.add(self.tracks[1])
self.history._add_track(self.tracks[1])
self.assertEqual(self.history.get_length(), 2)

self.history.add(self.tracks[2])
self.history._add_track(self.tracks[2])
self.assertEqual(self.history.get_length(), 3)

def test_non_tracks_are_rejected(self):
with self.assertRaises(TypeError):
self.history.add(object())
self.history._add_track(object())

self.assertEqual(self.history.get_length(), 0)

def test_history_entry_contents(self):
track = self.tracks[0]
self.history.add(track)
self.history._add_track(track)

result = self.history.get_history()
(timestamp, ref) = result[0]
Expand Down