diff --git a/mopidy/core/history.py b/mopidy/core/history.py index 23f5d74f..b66cd078 100644 --- a/mopidy/core/history.py +++ b/mopidy/core/history.py @@ -20,9 +20,8 @@ class HistoryController(object): :param track: track to change to :type track: :class:`mopidy.models.Track` """ - if type(track) is not models.Track: - logger.warning('Cannot add non-Track type object to TrackHistory') - return + if not isinstance(track, models.Track): + raise TypeError('Only Track objects can be added to the history') timestamp = int(time.time() * 1000) diff --git a/tests/core/test_history.py b/tests/core/test_history.py index 3592274c..ed918c1f 100644 --- a/tests/core/test_history.py +++ b/tests/core/test_history.py @@ -23,12 +23,11 @@ class PlaybackHistoryTest(unittest.TestCase): self.history.add(self.tracks[2]) self.assertEqual(self.history.size, 3) - def test_unsuitable_add(self): - size = self.history.size - self.history.add(self.tracks[0]) - self.history.add(object()) - self.history.add(self.tracks[1]) - self.assertEqual(self.history.size, size + 2) + def test_non_tracks_are_rejected(self): + with self.assertRaises(TypeError): + self.history.add(object()) + + self.assertEqual(self.history.size, 0) def test_history_sanity(self): track = self.tracks[0]