mpd: Refresh mapping when name is not present (Fixes #1348)

This commit is contained in:
Thomas Adamcik 2015-12-05 12:49:45 +01:00
parent 98e19e803b
commit c3393d3d85
2 changed files with 22 additions and 1 deletions

View File

@ -71,7 +71,7 @@ class MpdUriMapper(object):
"""
Helper function to retrieve a playlist URI from its unique MPD name.
"""
if not self._uri_from_name:
if name not in self._uri_from_name:
self.refresh_playlists_mapping()
return self._uri_from_name.get(name)

View File

@ -233,3 +233,24 @@ class IssueGH1120RegressionTest(protocol.BaseTestCase):
response2 = self.send_request('lsinfo "/"')
self.assertEqual(response1, response2)
class IssueGH1348RegressionTest(protocol.BaseTestCase):
"""
The issue: http://github.com/mopidy/mopidy/issues/1348
"""
def test(self):
self.backend.library.dummy_library = [Track(uri='dummy:a')]
# Create a dummy playlist and trigger population of mapping
self.send_request('playlistadd "testing1" "dummy:a"')
self.send_request('listplaylists')
# Create an other playlist which isn't in the map
self.send_request('playlistadd "testing2" "dummy:a"')
self.assertEqual(['OK'], self.send_request('rm "testing2"'))
playlists = self.backend.playlists.as_list().get()
self.assertEqual(['testing1'], [ref.name for ref in playlists])