client: add set_self_deaf server notification
This commit is contained in:
@@ -181,6 +181,14 @@ class MumbleClient:
|
|||||||
if self._mumble and self._connected:
|
if self._mumble and self._connected:
|
||||||
self._mumble.channels[channel_id].move_in()
|
self._mumble.channels[channel_id].move_in()
|
||||||
|
|
||||||
|
def set_self_deaf(self, deaf: bool):
|
||||||
|
"""Toggle self-deafen on the server."""
|
||||||
|
if self._mumble and self._connected:
|
||||||
|
if deaf:
|
||||||
|
self._mumble.users.myself.deafen()
|
||||||
|
else:
|
||||||
|
self._mumble.users.myself.undeafen()
|
||||||
|
|
||||||
# -- pymumble callbacks (run on pymumble thread) -------------------------
|
# -- pymumble callbacks (run on pymumble thread) -------------------------
|
||||||
|
|
||||||
def _register_callbacks(self):
|
def _register_callbacks(self):
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
"""Tests for MumbleClient dispatcher and callback wiring."""
|
"""Tests for MumbleClient dispatcher and callback wiring."""
|
||||||
|
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from tuimble.client import MumbleClient
|
from tuimble.client import MumbleClient
|
||||||
|
|
||||||
|
|
||||||
@@ -39,3 +41,29 @@ def test_dispatch_skips_none_callback():
|
|||||||
client = MumbleClient(host="localhost")
|
client = MumbleClient(host="localhost")
|
||||||
# Should not raise
|
# Should not raise
|
||||||
client._dispatch(None)
|
client._dispatch(None)
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_self_deaf_calls_pymumble():
|
||||||
|
client = MumbleClient(host="localhost")
|
||||||
|
client._connected = True
|
||||||
|
myself = MagicMock()
|
||||||
|
users = MagicMock()
|
||||||
|
users.myself = myself
|
||||||
|
mumble = MagicMock()
|
||||||
|
mumble.users = users
|
||||||
|
client._mumble = mumble
|
||||||
|
|
||||||
|
client.set_self_deaf(True)
|
||||||
|
myself.deafen.assert_called_once()
|
||||||
|
myself.undeafen.assert_not_called()
|
||||||
|
|
||||||
|
myself.reset_mock()
|
||||||
|
client.set_self_deaf(False)
|
||||||
|
myself.undeafen.assert_called_once()
|
||||||
|
myself.deafen.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_self_deaf_noop_when_disconnected():
|
||||||
|
client = MumbleClient(host="localhost")
|
||||||
|
# Should not raise when not connected
|
||||||
|
client.set_self_deaf(True)
|
||||||
|
|||||||
Reference in New Issue
Block a user