Implement MpdHandler.find_exact()

This commit is contained in:
Stein Magnus Jodal 2010-02-24 08:40:28 +01:00
parent d1ff2e9aea
commit e61ce61741
2 changed files with 12 additions and 6 deletions

View File

@ -345,7 +345,10 @@ class MpdHandler(object):
Finds songs in the db that are exactly ``WHAT``. ``TYPE`` should be
``album``, ``artist``, or ``title``. ``WHAT`` is what to find.
"""
raise MpdNotImplemented # TODO
if type == u'title':
type = u'track'
return self.backend.library.find_exact(type, what).mpd_format(
search_result=True)
@handle_pattern(r'^findadd "(?P<type>(album|artist|title))" "(?P<what>[^"]+)"$')
def _findadd(self, type, what):
@ -971,6 +974,8 @@ class MpdHandler(object):
``title``, ``artist``, ``album`` or ``filename``. Search is not
case sensitive.
"""
if type == u'title':
type = u'track'
return self.backend.library.search(type, what).mpd_format(
search_result=True)

View File

@ -674,7 +674,8 @@ class StoredPlaylistsHandlerTest(unittest.TestCase):
class MusicDatabaseHandlerTest(unittest.TestCase):
def setUp(self):
self.h = handler.MpdHandler(backend=DummyBackend())
self.b = DummyBackend()
self.h = handler.MpdHandler(backend=self.b)
def test_count(self):
result = self.h.handle_request(u'count "tag" "needle"')
@ -682,15 +683,15 @@ class MusicDatabaseHandlerTest(unittest.TestCase):
def test_find_album(self):
result = self.h.handle_request(u'find "album" "what"')
self.assert_(u'ACK Not implemented' in result)
self.assert_(u'OK' in result)
def test_find_artist(self):
result = self.h.handle_request(u'find "artist" "what"')
self.assert_(u'ACK Not implemented' in result)
self.assert_(u'OK' in result)
def test_find_title(self):
result = self.h.handle_request(u'find "title" "what"')
self.assert_(u'ACK Not implemented' in result)
self.assert_(u'OK' in result)
def test_find_else_should_fail(self):
try:
@ -701,7 +702,7 @@ class MusicDatabaseHandlerTest(unittest.TestCase):
def test_findadd(self):
result = self.h.handle_request(u'findadd "album" "what"')
self.assert_(u'ACK Not implemented' in result)
self.assert_(u'OK' in result)
def test_list_artist(self):
result = self.h.handle_request(u'list "artist"')