fix: DDP set_status auf UserPresence:setDefaultStatus umgestellt — falsche API-Methode war Root Cause fuer unsichtbaren Status
This commit is contained in:
+2
-2
@@ -544,8 +544,8 @@ class DDPClient:
|
|||||||
def set_status(self, status: str) -> bool:
|
def set_status(self, status: str) -> bool:
|
||||||
if not self.connected:
|
if not self.connected:
|
||||||
return False
|
return False
|
||||||
method = f"UserPresence:{status}"
|
method = "UserPresence:setDefaultStatus"
|
||||||
self._send_json({"msg": "method", "method": method, "params": [], "id": f"st{int(time.time()*1000)}"})
|
self._send_json({"msg": "method", "method": method, "params": [status], "id": f"st{int(time.time()*1000)}"})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
|
|||||||
@@ -129,3 +129,74 @@ class TestDDPRoomEvents:
|
|||||||
|
|
||||||
client._handle_ddp_message(event_data)
|
client._handle_ddp_message(event_data)
|
||||||
assert len(received_events) == 0
|
assert len(received_events) == 0
|
||||||
|
|
||||||
|
|
||||||
|
class TestDDPSetStatus:
|
||||||
|
"""Tests für DDPClient.set_status — P0 Fix: UserPresence:setDefaultStatus."""
|
||||||
|
|
||||||
|
def test_set_status_online_sends_correct_json(self):
|
||||||
|
"""set_status('online') sendet UserPresence:setDefaultStatus mit params=['online']."""
|
||||||
|
from adapter import DDPClient
|
||||||
|
|
||||||
|
client = DDPClient("test.example.com")
|
||||||
|
client.connected = True
|
||||||
|
client.sock = MagicMock()
|
||||||
|
|
||||||
|
with patch.object(client, "_send_json") as mock_send:
|
||||||
|
result = client.set_status("online")
|
||||||
|
|
||||||
|
assert result is True
|
||||||
|
mock_send.assert_called_once()
|
||||||
|
call_args = mock_send.call_args[0][0]
|
||||||
|
assert call_args["msg"] == "method"
|
||||||
|
assert call_args["method"] == "UserPresence:setDefaultStatus"
|
||||||
|
assert call_args["params"] == ["online"]
|
||||||
|
assert call_args["id"].startswith("st")
|
||||||
|
|
||||||
|
def test_set_status_away_sends_correct_json(self):
|
||||||
|
"""set_status('away') sendet UserPresence:setDefaultStatus mit params=['away']."""
|
||||||
|
from adapter import DDPClient
|
||||||
|
|
||||||
|
client = DDPClient("test.example.com")
|
||||||
|
client.connected = True
|
||||||
|
client.sock = MagicMock()
|
||||||
|
|
||||||
|
with patch.object(client, "_send_json") as mock_send:
|
||||||
|
result = client.set_status("away")
|
||||||
|
|
||||||
|
assert result is True
|
||||||
|
mock_send.assert_called_once()
|
||||||
|
call_args = mock_send.call_args[0][0]
|
||||||
|
assert call_args["msg"] == "method"
|
||||||
|
assert call_args["method"] == "UserPresence:setDefaultStatus"
|
||||||
|
assert call_args["params"] == ["away"]
|
||||||
|
assert call_args["id"].startswith("st")
|
||||||
|
|
||||||
|
def test_set_status_busy_sends_correct_json(self):
|
||||||
|
"""set_status('busy') sendet UserPresence:setDefaultStatus mit params=['busy']."""
|
||||||
|
from adapter import DDPClient
|
||||||
|
|
||||||
|
client = DDPClient("test.example.com")
|
||||||
|
client.connected = True
|
||||||
|
client.sock = MagicMock()
|
||||||
|
|
||||||
|
with patch.object(client, "_send_json") as mock_send:
|
||||||
|
result = client.set_status("busy")
|
||||||
|
|
||||||
|
assert result is True
|
||||||
|
mock_send.assert_called_once()
|
||||||
|
call_args = mock_send.call_args[0][0]
|
||||||
|
assert call_args["msg"] == "method"
|
||||||
|
assert call_args["method"] == "UserPresence:setDefaultStatus"
|
||||||
|
assert call_args["params"] == ["busy"]
|
||||||
|
assert call_args["id"].startswith("st")
|
||||||
|
|
||||||
|
def test_set_status_disconnected_returns_false(self):
|
||||||
|
"""set_status gibt False zurück wenn nicht connected."""
|
||||||
|
from adapter import DDPClient
|
||||||
|
|
||||||
|
client = DDPClient("test.example.com")
|
||||||
|
client.connected = False
|
||||||
|
|
||||||
|
result = client.set_status("online")
|
||||||
|
assert result is False
|
||||||
|
|||||||
Reference in New Issue
Block a user