Address review comments

This commit is contained in:
Lasse Bigum 2013-11-13 00:40:47 +01:00
parent 9ba5f6862f
commit f5e94d8f7c
6 changed files with 16 additions and 17 deletions

View File

@ -106,7 +106,7 @@ def find(context, mpd_query):
'composer' not in query and
'performer' not in query):
result_tracks += [_artist_as_track(a) for a in _get_artists(results)]
if 'album' not in query and 'genre' not in query:
if 'album' not in query:
result_tracks += [_album_as_track(a) for a in _get_albums(results)]
result_tracks += _get_tracks(results)
return translator.tracks_to_mpd_format(result_tracks)

View File

@ -219,10 +219,10 @@ class Track(ImmutableObject):
:type artists: list of :class:`Artist`
:param album: track album
:type album: :class:`Album`
:param composer: track composer
:type composer: string
:param performer: track performer
:type performer: string
:param composers: track composers
:type composers: string
:param performers: track performers
:type performers: string
:param genre: track genre
:type genre: string
:param track_no: track number in album

View File

@ -48,8 +48,7 @@ class LocalLibraryProviderTest(unittest.TestCase):
uri='local:track:path4', name='track4',
artists=[artists[2]], album=albums[3],
date='2004', length=60000, track_no=4,
comment='Music server with support for MPD/HTTP clients '
'and Spotify streaming http://www.mopidy.com'),
comment='This is a fantastic track'),
Track(
uri='local:track:path5', name='track5', genre='genre1',
album=albums[3], length=4000, composers=[artists[4]]),
@ -242,12 +241,11 @@ class LocalLibraryProviderTest(unittest.TestCase):
def test_find_exact_comment(self):
result = self.library.find_exact(
comment=['Music server with support for MPD/HTTP clients '
'and Spotify streaming http://www.mopidy.com'])
comment=['This is a fantastic track'])
self.assertEqual(list(result[0].tracks), self.tracks[3:4])
result = self.library.find_exact(
comment=['Music server with support for MPD/HTTP clients'])
comment=['This is a fantastic'])
self.assertEqual(list(result[0].tracks), [])
def test_find_exact_any(self):
@ -295,8 +293,7 @@ class LocalLibraryProviderTest(unittest.TestCase):
# Matches on track comment
result = self.library.find_exact(
any=['Music server with support for MPD/HTTP clients '
'and Spotify streaming http://www.mopidy.com'])
any=['This is a fantastic track'])
self.assertEqual(list(result[0].tracks), self.tracks[3:4])
# Matches on URI
@ -458,10 +455,10 @@ class LocalLibraryProviderTest(unittest.TestCase):
self.assertEqual(list(result[0].tracks), self.tracks[1:2])
def test_search_comment(self):
result = self.library.search(comment=['mopidy'])
result = self.library.search(comment=['fantastic'])
self.assertEqual(list(result[0].tracks), self.tracks[3:4])
result = self.library.search(comment=['Potify'])
result = self.library.search(comment=['antasti'])
self.assertEqual(list(result[0].tracks), self.tracks[3:4])
def test_search_any(self):
@ -501,10 +498,10 @@ class LocalLibraryProviderTest(unittest.TestCase):
self.assertEqual(list(result[0].tracks), self.tracks[5:6])
# Matches on track comment
result = self.library.search(any=['http'])
result = self.library.search(any=['fanta'])
self.assertEqual(list(result[0].tracks), self.tracks[3:4])
result = self.library.search(any=['streaming'])
result = self.library.search(any=['is a fan'])
self.assertEqual(list(result[0].tracks), self.tracks[3:4])
# Matches on URI

View File

@ -37,7 +37,7 @@ Title: track4
Album: album4
Date: 2004
Track: 4
Comment: Music server with support for MPD/HTTP clients and Spotify streaming http://www.mopidy.com
Comment: This is a fantastic track
Time: 60
key: key5
file: /path5

View File

@ -21,6 +21,7 @@ class StatusHandlerTest(protocol.BaseTestCase):
self.assertInResponse('Title: ')
self.assertInResponse('Album: ')
self.assertInResponse('Track: 0')
self.assertNotInResponse('Date: ')
self.assertInResponse('Pos: 0')
self.assertInResponse('Id: 0')
self.assertInResponse('OK')

View File

@ -41,6 +41,7 @@ class TrackMpdFormatTest(unittest.TestCase):
self.assertIn(('Title', ''), result)
self.assertIn(('Album', ''), result)
self.assertIn(('Track', 0), result)
self.assertNotIn(('Date', ''), result)
self.assertEqual(len(result), 6)
def test_track_to_mpd_format_with_position(self):