From 1a5263b68ff193941ec8d7af941fa8a94ad7e5a4 Mon Sep 17 00:00:00 2001 From: Carl Suster Date: Mon, 15 Apr 2019 14:19:09 +1000 Subject: [PATCH] bpd: support volume command for real --- beetsplug/bpd/__init__.py | 3 ++- test/test_player.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/beetsplug/bpd/__init__.py b/beetsplug/bpd/__init__.py index 5bf35e1d5..05bde6d33 100644 --- a/beetsplug/bpd/__init__.py +++ b/beetsplug/bpd/__init__.py @@ -454,7 +454,8 @@ class BaseServer(object): def cmd_volume(self, conn, vol_delta): """Deprecated command to change the volume by a relative amount.""" - raise BPDError(ERROR_SYSTEM, u'No mixer') + vol_delta = cast_arg(int, vol_delta) + return self.cmd_setvol(conn, self.volume + vol_delta) def cmd_crossfade(self, conn, crossfade): """Set the number of seconds of crossfading.""" diff --git a/test/test_player.py b/test/test_player.py index b4ed03618..048f2cedd 100644 --- a/test/test_player.py +++ b/test/test_player.py @@ -623,8 +623,13 @@ class BPDPlaybackTest(BPDTestHelper): def test_cmd_volume(self): with self.run_bpd() as client: - response = client.send_command('volume', '10') - self._assert_failed(response, bpd.ERROR_SYSTEM) + responses = client.send_commands( + ('setvol', '10'), + ('volume', '5'), + ('volume', '-2'), + ('status',)) + self._assert_ok(*responses) + self.assertEqual('13', responses[3].data['volume']) def test_cmd_replay_gain(self): with self.run_bpd() as client: