Skip to content

Commit

Permalink
Merge pull request #30 from HEnquist/next202
Browse files Browse the repository at this point in the history
Fix typos, add tests for mute
  • Loading branch information
HEnquist committed Jan 8, 2024
2 parents 46ded4e + 0db35dd commit f2d7711
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions camilladsp/camilladsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
_reason_from_reply,
)

VERSION = "2.0.1"
VERSION = "2.0.2"


class CamillaError(ValueError):
Expand Down Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
18 changes: 16 additions & 2 deletions tests/test_camillaws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}
),
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand All @@ -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):
Expand Down

0 comments on commit f2d7711

Please sign in to comment.