From 635791cf0e7c65dc152bc085a1ab43a314008685 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 13 Aug 2010 13:33:09 +0200 Subject: [PATCH] MPD: Support missing quotes for 'consume', 'random', 'repeat', and 'single' to work with BitMPC. --- docs/changes.rst | 4 +-- mopidy/frontends/mpd/protocol/playback.py | 4 +++ tests/frontends/mpd/playback_test.py | 40 +++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index c8094546..c805b595 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -25,8 +25,8 @@ Another great release. - Fixed ``play "-1"`` and ``playid "-1"`` behaviour when playlist is empty. - Support ``plchanges "-1"`` to work better with MPDroid. - Support ``pause`` without arguments to work better with MPDroid. - - Support ``plchanges`` without quotes to work better with BitMPC. - - Support ``play`` without quotes to work better with BitMPC. + - Support ``plchanges``, ``play``, ``consume``, ``random``, ``repeat``, and + ``single`` without quotes to work better with BitMPC. - Backend API: diff --git a/mopidy/frontends/mpd/protocol/playback.py b/mopidy/frontends/mpd/protocol/playback.py index 8a7243f6..cf803c6d 100644 --- a/mopidy/frontends/mpd/protocol/playback.py +++ b/mopidy/frontends/mpd/protocol/playback.py @@ -1,6 +1,7 @@ from mopidy.frontends.mpd import (handle_pattern, MpdArgError, MpdNoExistError, MpdNotImplemented) +@handle_pattern(r'^consume (?P[01])$') @handle_pattern(r'^consume "(?P[01])"$') def consume(frontend, state): """ @@ -224,6 +225,7 @@ def previous(frontend): """ return frontend.backend.playback.previous() +@handle_pattern(r'^random (?P[01])$') @handle_pattern(r'^random "(?P[01])"$') def random(frontend, state): """ @@ -238,6 +240,7 @@ def random(frontend, state): else: frontend.backend.playback.random = False +@handle_pattern(r'^repeat (?P[01])$') @handle_pattern(r'^repeat "(?P[01])"$') def repeat(frontend, state): """ @@ -319,6 +322,7 @@ def setvol(frontend, volume): volume = 100 frontend.backend.mixer.volume = volume +@handle_pattern(r'^single (?P[01])$') @handle_pattern(r'^single "(?P[01])"$') def single(frontend, state): """ diff --git a/tests/frontends/mpd/playback_test.py b/tests/frontends/mpd/playback_test.py index 6e69375b..3cf0a11f 100644 --- a/tests/frontends/mpd/playback_test.py +++ b/tests/frontends/mpd/playback_test.py @@ -16,11 +16,21 @@ class PlaybackOptionsHandlerTest(unittest.TestCase): self.assertFalse(self.b.playback.consume) self.assert_(u'OK' in result) + def test_consume_off_without_quotes(self): + result = self.h.handle_request(u'consume 0') + self.assertFalse(self.b.playback.consume) + self.assert_(u'OK' in result) + def test_consume_on(self): result = self.h.handle_request(u'consume "1"') self.assertTrue(self.b.playback.consume) self.assert_(u'OK' in result) + def test_consume_on_without_quotes(self): + result = self.h.handle_request(u'consume 1') + self.assertTrue(self.b.playback.consume) + self.assert_(u'OK' in result) + def test_crossfade(self): result = self.h.handle_request(u'crossfade "10"') self.assert_(u'ACK [0@0] {} Not implemented' in result) @@ -30,21 +40,41 @@ class PlaybackOptionsHandlerTest(unittest.TestCase): self.assertFalse(self.b.playback.random) self.assert_(u'OK' in result) + def test_random_off_without_quotes(self): + result = self.h.handle_request(u'random 0') + self.assertFalse(self.b.playback.random) + self.assert_(u'OK' in result) + def test_random_on(self): result = self.h.handle_request(u'random "1"') self.assertTrue(self.b.playback.random) self.assert_(u'OK' in result) + def test_random_on_without_quotes(self): + result = self.h.handle_request(u'random 1') + self.assertTrue(self.b.playback.random) + self.assert_(u'OK' in result) + def test_repeat_off(self): result = self.h.handle_request(u'repeat "0"') self.assertFalse(self.b.playback.repeat) self.assert_(u'OK' in result) + def test_repeat_off_without_quotes(self): + result = self.h.handle_request(u'repeat 0') + self.assertFalse(self.b.playback.repeat) + self.assert_(u'OK' in result) + def test_repeat_on(self): result = self.h.handle_request(u'repeat "1"') self.assertTrue(self.b.playback.repeat) self.assert_(u'OK' in result) + def test_repeat_on_without_quotes(self): + result = self.h.handle_request(u'repeat 1') + self.assertTrue(self.b.playback.repeat) + self.assert_(u'OK' in result) + def test_setvol_below_min(self): result = self.h.handle_request(u'setvol "-10"') self.assert_(u'OK' in result) @@ -80,11 +110,21 @@ class PlaybackOptionsHandlerTest(unittest.TestCase): self.assertFalse(self.b.playback.single) self.assert_(u'OK' in result) + def test_single_off_without_quotes(self): + result = self.h.handle_request(u'single 0') + self.assertFalse(self.b.playback.single) + self.assert_(u'OK' in result) + def test_single_on(self): result = self.h.handle_request(u'single "1"') self.assertTrue(self.b.playback.single) self.assert_(u'OK' in result) + def test_single_on_without_quotes(self): + result = self.h.handle_request(u'single 1') + self.assertTrue(self.b.playback.single) + self.assert_(u'OK' in result) + def test_replay_gain_mode_off(self): result = self.h.handle_request(u'replay_gain_mode "off"') self.assert_(u'ACK [0@0] {} Not implemented' in result)