mpd: Allow full MPD queries to 'count'

Fix hechtus/mopidy-gmusic#1
This commit is contained in:
Stein Magnus Jodal 2013-07-09 11:48:11 +02:00
parent 99eed0e6b8
commit 579a93437f
2 changed files with 11 additions and 4 deletions

View File

@ -39,8 +39,8 @@ def _artist_as_track(artist):
artists=[artist])
@handle_request(r'^count "?(?P<tag>[^"]+)"? "(?P<needle>[^"]*)"$')
def count(context, tag, needle):
@handle_request(r'^count ' + QUERY_RE)
def count(context, mpd_query):
"""
*musicpd.org, music database section:*
@ -52,6 +52,7 @@ def count(context, tag, needle):
*GMPC:*
- does not add quotes around the tag argument.
- use multiple tag-needle pairs to make more specific searches.
"""
return [('songs', 0), ('playtime', 0)] # TODO

View File

@ -7,13 +7,19 @@ from tests.frontends.mpd import protocol
class MusicDatabaseHandlerTest(protocol.BaseTestCase):
def test_count(self):
self.sendRequest('count "tag" "needle"')
self.sendRequest('count "artist" "needle"')
self.assertInResponse('songs: 0')
self.assertInResponse('playtime: 0')
self.assertInResponse('OK')
def test_count_without_quotes(self):
self.sendRequest('count tag "needle"')
self.sendRequest('count artist "needle"')
self.assertInResponse('songs: 0')
self.assertInResponse('playtime: 0')
self.assertInResponse('OK')
def test_count_with_multiple_pairs(self):
self.sendRequest('count "artist" "foo" "album" "bar"')
self.assertInResponse('songs: 0')
self.assertInResponse('playtime: 0')
self.assertInResponse('OK')