From c9506ca7e1d37fcc9f6f0743ab2b7941cd7afdd1 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 3 Jun 2011 23:32:19 +0200 Subject: [PATCH] List 'kill' MPD command in 'notcommands' instead of 'commands' --- mopidy/frontends/mpd/protocol/reflection.py | 11 ++++++++++- tests/frontends/mpd/reflection_test.py | 7 +++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/mopidy/frontends/mpd/protocol/reflection.py b/mopidy/frontends/mpd/protocol/reflection.py index 181dce54..2b319c5e 100644 --- a/mopidy/frontends/mpd/protocol/reflection.py +++ b/mopidy/frontends/mpd/protocol/reflection.py @@ -17,6 +17,9 @@ def commands(context): sorted_commands = sorted(list(mpd_commands)) + # No permission to use + sorted_commands.remove('kill') + # Not shown by MPD in its command list sorted_commands.remove('command_list_begin') sorted_commands.remove('command_list_ok_begin') @@ -59,7 +62,13 @@ def notcommands(context): # authenticated, 'notcommands' should list all the commands the client does # not have access to. To implement this we need access to the session # object to check if the client is authenticated or not. - pass + + commands = [] + + # No permission to use + commands.append('kill') + + return [('command', c) for c in sorted(commands)] @handle_pattern(r'^tagtypes$') def tagtypes(context): diff --git a/tests/frontends/mpd/reflection_test.py b/tests/frontends/mpd/reflection_test.py index c5cde1bb..adc34338 100644 --- a/tests/frontends/mpd/reflection_test.py +++ b/tests/frontends/mpd/reflection_test.py @@ -20,6 +20,8 @@ class ReflectionHandlerTest(unittest.TestCase): self.assert_(u'command: commands' in result) self.assert_(u'command: play' in result) self.assert_(u'command: status' in result) + # Check if commands you do not have access to are not present + self.assert_(u'command: kill' not in result) # Check if the blacklisted commands are not present self.assert_(u'command: command_list_begin' not in result) self.assert_(u'command: command_list_ok_begin' not in result) @@ -33,9 +35,10 @@ class ReflectionHandlerTest(unittest.TestCase): result = self.dispatcher.handle_request(u'decoders') self.assert_(u'ACK [0@0] {} Not implemented' in result) - def test_notcommands_returns_only_ok(self): + def test_notcommands_returns_only_kill_and_ok(self): result = self.dispatcher.handle_request(u'notcommands') - self.assertEqual(1, len(result)) + self.assertEqual(2, len(result)) + self.assert_(u'command: kill' in result) self.assert_(u'OK' in result) def test_tagtypes(self):