mpd: list shouldn't return blank artist names, album names, or dates

This commit is contained in:
Stein Magnus Jodal 2012-11-21 00:48:08 +01:00
parent 72574c1ae0
commit 5fbb6328d6
4 changed files with 36 additions and 5 deletions

View File

@ -82,6 +82,9 @@ long time been our most requested feature. Finally, it's here!
- The MPD command ``listplaylists`` will no longer return playlists without a - The MPD command ``listplaylists`` will no longer return playlists without a
name. This could crash ncmpcpp. name. This could crash ncmpcpp.
- The MPD command ``list`` will no longer return artist names, album names, or
dates that are blank.
**MPRIS frontend** **MPRIS frontend**
- The MPRIS playlists interface is now supported by our MPRIS frontend. This - The MPRIS playlists interface is now supported by our MPRIS frontend. This

View File

@ -37,9 +37,11 @@ class DummyLibraryProvider(base.BaseLibraryProvider):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(DummyLibraryProvider, self).__init__(*args, **kwargs) super(DummyLibraryProvider, self).__init__(*args, **kwargs)
self.dummy_library = [] self.dummy_library = []
self.dummy_find_exact_result = []
self.dummy_search_result = []
def find_exact(self, **query): def find_exact(self, **query):
return [] return self.dummy_find_exact_result
def lookup(self, uri): def lookup(self, uri):
return filter(lambda t: uri == t.uri, self.dummy_library) return filter(lambda t: uri == t.uri, self.dummy_library)
@ -48,7 +50,7 @@ class DummyLibraryProvider(base.BaseLibraryProvider):
pass pass
def search(self, **query): def search(self, **query):
return [] return self.dummy_search_result
class DummyPlaybackProvider(base.BasePlaybackProvider): class DummyPlaybackProvider(base.BasePlaybackProvider):

View File

@ -250,7 +250,8 @@ def _list_artist(context, query):
tracks = context.core.library.find_exact(**query).get() tracks = context.core.library.find_exact(**query).get()
for track in tracks: for track in tracks:
for artist in track.artists: for artist in track.artists:
artists.add(('Artist', artist.name)) if artist.name:
artists.add(('Artist', artist.name))
return artists return artists
@ -258,7 +259,7 @@ def _list_album(context, query):
albums = set() albums = set()
tracks = context.core.library.find_exact(**query).get() tracks = context.core.library.find_exact(**query).get()
for track in tracks: for track in tracks:
if track.album is not None: if track.album and track.album.name:
albums.add(('Album', track.album.name)) albums.add(('Album', track.album.name))
return albums return albums
@ -267,7 +268,7 @@ def _list_date(context, query):
dates = set() dates = set()
tracks = context.core.library.find_exact(**query).get() tracks = context.core.library.find_exact(**query).get()
for track in tracks: for track in tracks:
if track.date is not None: if track.date:
dates.add(('Date', track.date)) dates.add(('Date', track.date))
return dates return dates

View File

@ -1,5 +1,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from mopidy.models import Album, Artist, Track
from tests.frontends.mpd import protocol from tests.frontends.mpd import protocol
@ -181,6 +183,14 @@ class MusicDatabaseListTest(protocol.BaseTestCase):
self.sendRequest('list "artist" "artist" ""') self.sendRequest('list "artist" "artist" ""')
self.assertInResponse('OK') self.assertInResponse('OK')
def test_list_artist_should_not_return_artists_without_names(self):
self.backend.library.dummy_find_exact_result = [
Track(artists=[Artist(name='')])]
self.sendRequest('list "artist"')
self.assertNotInResponse('Artist: ')
self.assertInResponse('OK')
### Album ### Album
def test_list_album_with_quotes(self): def test_list_album_with_quotes(self):
@ -232,6 +242,14 @@ class MusicDatabaseListTest(protocol.BaseTestCase):
self.sendRequest('list "album" "artist" ""') self.sendRequest('list "album" "artist" ""')
self.assertInResponse('OK') self.assertInResponse('OK')
def test_list_album_should_not_return_albums_without_names(self):
self.backend.library.dummy_find_exact_result = [
Track(album=Album(name=''))]
self.sendRequest('list "album"')
self.assertNotInResponse('Album: ')
self.assertInResponse('OK')
### Date ### Date
def test_list_date_with_quotes(self): def test_list_date_with_quotes(self):
@ -279,6 +297,13 @@ class MusicDatabaseListTest(protocol.BaseTestCase):
self.sendRequest('list "date" "artist" ""') self.sendRequest('list "date" "artist" ""')
self.assertInResponse('OK') self.assertInResponse('OK')
def test_list_date_should_not_return_blank_dates(self):
self.backend.library.dummy_find_exact_result = [Track(date='')]
self.sendRequest('list "date"')
self.assertNotInResponse('Date: ')
self.assertInResponse('OK')
### Genre ### Genre
def test_list_genre_with_quotes(self): def test_list_genre_with_quotes(self):