'command_list_end' before 'command_list_start' now returns 'unknown command' error instead of crashing
This commit is contained in:
parent
873e387618
commit
d093e498d8
@ -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 = []
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user