From 2f9775250a0a08f5b1cc5b3675234c7a2aaa8e57 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 23 Jun 2010 22:53:27 +0200 Subject: [PATCH] Return 'incorrect arguments' instead of 'unknown command' for known commands that don't match any patterns --- mopidy/mpd/frontend.py | 5 ++++- tests/mpd/frontend_test.py | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mopidy/mpd/frontend.py b/mopidy/mpd/frontend.py index 58402959..c45ef4f2 100644 --- a/mopidy/mpd/frontend.py +++ b/mopidy/mpd/frontend.py @@ -79,7 +79,10 @@ class MpdFrontend(object): matches = re.match(pattern, request) if matches is not None: return (_request_handlers[pattern], matches.groupdict()) - raise MpdUnknownCommand(command=request.split(' ')[0]) + command = request.split(' ')[0] + if command in _commands: + raise MpdArgError(u'incorrect arguments', command=command) + raise MpdUnknownCommand(command=command) def handle_response(self, result, add_ok=True): response = [] diff --git a/tests/mpd/frontend_test.py b/tests/mpd/frontend_test.py index 6cb77415..a03d1b17 100644 --- a/tests/mpd/frontend_test.py +++ b/tests/mpd/frontend_test.py @@ -993,8 +993,7 @@ class MusicDatabaseHandlerTest(unittest.TestCase): def test_list_artist_with_artist_should_fail(self): result = self.h.handle_request(u'list "artist" "anartist"') - self.assertEqual(result[0], - u'ACK [2@0] {list} should be "Album" for 3 arguments') + self.assertEqual(result[0], u'ACK [2@0] {list} incorrect arguments') def test_list_album_without_artist(self): result = self.h.handle_request(u'list "album"')