MPD: Implement 'commands' command
This commit is contained in:
parent
c6cd2ba564
commit
d00c47ec88
@ -1090,8 +1090,16 @@ class MpdFrontend(object):
|
||||
``commands``
|
||||
|
||||
Shows which commands the current user has access to.
|
||||
|
||||
As permissions is not implemented, any user has access to all commands.
|
||||
"""
|
||||
pass # TODO
|
||||
commands = set()
|
||||
for command_pattern in _request_handlers.keys():
|
||||
match = re.search('([a-z_]+)', command_pattern)
|
||||
if match is not None:
|
||||
commands.add(match.group())
|
||||
commands = sorted(list(commands))
|
||||
return [('command', command) for command in commands]
|
||||
|
||||
@handle_pattern(r'^decoders$')
|
||||
def _reflection_decoders(self):
|
||||
@ -1120,8 +1128,10 @@ class MpdFrontend(object):
|
||||
``notcommands``
|
||||
|
||||
Shows which commands the current user does not have access to.
|
||||
|
||||
As permissions is not implemented, any user has access to all commands.
|
||||
"""
|
||||
pass # TODO
|
||||
pass
|
||||
|
||||
@handle_pattern(r'^tagtypes$')
|
||||
def _reflection_tagtypes(self):
|
||||
|
||||
@ -1161,16 +1161,20 @@ class ReflectionHandlerTest(unittest.TestCase):
|
||||
self.b = DummyBackend(mixer=self.m)
|
||||
self.h = frontend.MpdFrontend(backend=self.b)
|
||||
|
||||
def test_commands(self):
|
||||
def test_commands_returns_list_of_all_commands(self):
|
||||
result = self.h.handle_request(u'commands')
|
||||
self.assert_(u'command: commands' in result)
|
||||
self.assert_(u'command: play' in result)
|
||||
self.assert_(u'command: status' in result)
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_decoders(self):
|
||||
result = self.h.handle_request(u'decoders')
|
||||
self.assert_(u'ACK Not implemented' in result)
|
||||
|
||||
def test_notcommands(self):
|
||||
def test_notcommands_returns_only_ok(self):
|
||||
result = self.h.handle_request(u'notcommands')
|
||||
self.assertEqual(1, len(result))
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_tagtypes(self):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user