diff --git a/mopidy/mpd/frontend.py b/mopidy/mpd/frontend.py index b0e2dac7..6b9052bd 100644 --- a/mopidy/mpd/frontend.py +++ b/mopidy/mpd/frontend.py @@ -169,6 +169,9 @@ class MpdFrontend(object): @handle_pattern(r'^command_list_end$') def _command_list_end(self): """See :meth:`_command_list_begin`.""" + if self.command_list is False: + # Test for False exactly, and not e.g. empty list + raise MpdUnknownCommand(command='command_list_end') (command_list, self.command_list) = (self.command_list, False) (command_list_ok, self.command_list_ok) = (self.command_list_ok, False) result = [] diff --git a/tests/mpd/frontend_test.py b/tests/mpd/frontend_test.py index d884ab73..1a5e484d 100644 --- a/tests/mpd/frontend_test.py +++ b/tests/mpd/frontend_test.py @@ -67,6 +67,11 @@ class CommandListsTest(unittest.TestCase): result = self.h.handle_request(u'command_list_end') self.assert_(u'OK' in result) + def test_command_list_end_without_start_first_is_an_unknown_command(self): + result = self.h.handle_request(u'command_list_end') + self.assertEquals(result[0], + u'ACK [5@0] {} unknown command "command_list_end"') + def test_command_list_with_ping(self): self.h.handle_request(u'command_list_begin') self.assertEqual([], self.h.command_list)