From 85a88a2c442ed5396b182a81817c05a610a6f9e8 Mon Sep 17 00:00:00 2001 From: Henrik Date: Sat, 6 Jan 2024 22:19:53 +0100 Subject: [PATCH 1/2] Fix typos, add tests for mute --- camilladsp/camilladsp.py | 2 +- docs/index.md | 1 + tests/test_camillaws.py | 18 ++++++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/camilladsp/camilladsp.py b/camilladsp/camilladsp.py index a4d05a0..9372b27 100644 --- a/camilladsp/camilladsp.py +++ b/camilladsp/camilladsp.py @@ -667,7 +667,7 @@ def toggle_fader(self, fader: int) -> bool: Returns: bool: True if the new status is muted, False otherwise. """ - _fader, new_mute = self.client.query("SetFaderMute", arg=int(fader)) + _fader, new_mute = self.client.query("ToggleFaderMute", arg=int(fader)) return new_mute diff --git a/docs/index.md b/docs/index.md index 14f6eb2..2ea604a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -19,6 +19,7 @@ and the method for changing the main volume is called `set_main`. Example: ```py client = CamillaClient("localhost", 1234) +client.connect() volume = client.volume.main() mute = client.mute.main() diff --git a/tests/test_camillaws.py b/tests/test_camillaws.py index 0b08dbb..87e6f3e 100644 --- a/tests/test_camillaws.py +++ b/tests/test_camillaws.py @@ -34,6 +34,15 @@ def __init__(self): '{"GetFaderVolume": 1}': json.dumps( {"GetFaderVolume": {"result": "Ok", "value": [1, -1.23]}} ), + '{"AdjustFaderVolume": [1, -2.5]}': json.dumps( + {"AdjustFaderVolume": {"result": "Ok", "value": [1, -3.73]}} + ), + '{"GetFaderMute": 1}': json.dumps( + {"GetFaderMute": {"result": "Ok", "value": [1, False]}} + ), + '{"ToggleFaderMute": 1}': json.dumps( + {"ToggleFaderMute": {"result": "Ok", "value": [1, True]}} + ), '"GetErrorValue"': json.dumps( {"GetErrorValue": {"result": "Error", "value": "badstuff"}} ), @@ -215,6 +224,9 @@ def test_query_mockedws(camilla_mockws): assert camilla_mockws.dummyws.query == json.dumps({"SetSomeValue": 123}) assert camilla_mockws.general.supported_device_types() == (["a", "b"], ["c", "d"]) assert camilla_mockws.volume.fader(1) == -1.23 + assert camilla_mockws.volume.adjust_fader(1, -2.5) == -3.73 + assert camilla_mockws.mute.fader(1) == False + assert camilla_mockws.mute.toggle_fader(1) == True def test_queries(camilla_mockquery): @@ -256,10 +268,14 @@ def test_queries(camilla_mockquery): camilla_mockquery.query.assert_called_with("GetVolume") camilla_mockquery.volume.set_main(-25.0) camilla_mockquery.query.assert_called_with("SetVolume", arg=-25.0) + camilla_mockquery.volume.set_fader(1, -1.23) + camilla_mockquery.query.assert_called_with("SetFaderVolume", arg=(1, -1.23)) camilla_mockquery.mute.main() camilla_mockquery.query.assert_called_with("GetMute") camilla_mockquery.mute.set_main(False) camilla_mockquery.query.assert_called_with("SetMute", arg=False) + camilla_mockquery.mute.set_fader(1, False) + camilla_mockquery.query.assert_called_with("SetFaderMute", arg=(1, False)) camilla_mockquery.levels.capture_rms() camilla_mockquery.query.assert_called_with("GetCaptureSignalRms") camilla_mockquery.levels.capture_peak() @@ -268,8 +284,6 @@ def test_queries(camilla_mockquery): camilla_mockquery.query.assert_called_with("GetPlaybackSignalRms") camilla_mockquery.levels.playback_peak() camilla_mockquery.query.assert_called_with("GetPlaybackSignalPeak") - camilla_mockquery.volume.set_fader(1, -1.23) - camilla_mockquery.query.assert_called_with("SetFaderVolume", arg=(1, -1.23)) def test_queries_adv(camilla_mockquery_yaml): From 0db35dd5be88fa49ddc740c33019aa85fb171b72 Mon Sep 17 00:00:00 2001 From: Henrik Enquist Date: Mon, 8 Jan 2024 22:56:04 +0100 Subject: [PATCH 2/2] Bump version to 2.0.2 --- camilladsp/camilladsp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camilladsp/camilladsp.py b/camilladsp/camilladsp.py index 9372b27..a41b1a1 100644 --- a/camilladsp/camilladsp.py +++ b/camilladsp/camilladsp.py @@ -27,7 +27,7 @@ _reason_from_reply, ) -VERSION = "2.0.1" +VERSION = "2.0.2" class CamillaError(ValueError):