Fix plchanges so it returns nothing when nothing has changed
This commit is contained in:
parent
0d16af97a5
commit
d985b8be38
@ -75,6 +75,9 @@ backends:
|
||||
- :issue:`218`: The MPD commands ``listplaylist`` and ``listplaylistinfo`` now
|
||||
accepts unquotes playlist names if they don't contain spaces.
|
||||
|
||||
- The MPD command ``plchanges`` always returned the entire playlist. It now
|
||||
returns an empty response when the client has seen the latest version.
|
||||
|
||||
|
||||
v0.8.1 (2012-10-30)
|
||||
===================
|
||||
|
||||
@ -307,7 +307,7 @@ def plchanges(context, version):
|
||||
- Calls ``plchanges "-1"`` two times per second to get the entire playlist.
|
||||
"""
|
||||
# XXX Naive implementation that returns all tracks as changed
|
||||
if int(version) < context.core.current_playlist.version:
|
||||
if int(version) < context.core.current_playlist.version.get():
|
||||
return translator.tracks_to_mpd_format(
|
||||
context.core.current_playlist.cp_tracks.get())
|
||||
|
||||
|
||||
@ -364,7 +364,7 @@ class CurrentPlaylistHandlerTest(protocol.BaseTestCase):
|
||||
self.sendRequest(u'playlistsearch any "needle"')
|
||||
self.assertEqualResponse(u'ACK [0@0] {} Not implemented')
|
||||
|
||||
def test_plchanges(self):
|
||||
def test_plchanges_with_lower_version_returns_changes(self):
|
||||
self.core.current_playlist.append(
|
||||
[Track(name='a'), Track(name='b'), Track(name='c')])
|
||||
|
||||
@ -374,6 +374,28 @@ class CurrentPlaylistHandlerTest(protocol.BaseTestCase):
|
||||
self.assertInResponse(u'Title: c')
|
||||
self.assertInResponse(u'OK')
|
||||
|
||||
def test_plchanges_with_equal_version_returns_nothing(self):
|
||||
self.core.current_playlist.append(
|
||||
[Track(name='a'), Track(name='b'), Track(name='c')])
|
||||
|
||||
self.assertEqual(self.core.current_playlist.version.get(), 1)
|
||||
self.sendRequest(u'plchanges "1"')
|
||||
self.assertNotInResponse(u'Title: a')
|
||||
self.assertNotInResponse(u'Title: b')
|
||||
self.assertNotInResponse(u'Title: c')
|
||||
self.assertInResponse(u'OK')
|
||||
|
||||
def test_plchanges_with_greater_version_returns_nothing(self):
|
||||
self.core.current_playlist.append(
|
||||
[Track(name='a'), Track(name='b'), Track(name='c')])
|
||||
|
||||
self.assertEqual(self.core.current_playlist.version.get(), 1)
|
||||
self.sendRequest(u'plchanges "2"')
|
||||
self.assertNotInResponse(u'Title: a')
|
||||
self.assertNotInResponse(u'Title: b')
|
||||
self.assertNotInResponse(u'Title: c')
|
||||
self.assertInResponse(u'OK')
|
||||
|
||||
def test_plchanges_with_minus_one_returns_entire_playlist(self):
|
||||
self.core.current_playlist.append(
|
||||
[Track(name='a'), Track(name='b'), Track(name='c')])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user