diff --git a/mopidy/mpd/frontend.py b/mopidy/mpd/frontend.py index 9aad5819..e0960286 100644 --- a/mopidy/mpd/frontend.py +++ b/mopidy/mpd/frontend.py @@ -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): diff --git a/tests/mpd/frontend_test.py b/tests/mpd/frontend_test.py index edacccf1..6f7e8ec6 100644 --- a/tests/mpd/frontend_test.py +++ b/tests/mpd/frontend_test.py @@ -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):