Raise a clear client error for a refused request

socket_comms now raises DaemonError with the server message if the reply has the status ERROR. Before, the reply reached code that expects device data, and that code raised KeyError.
This commit is contained in:
tim
2026-10-10 10:59:35 +02:00
parent 0d5a080425
commit 9ab1d909ed
3 changed files with 50 additions and 0 deletions
+15
View File
@@ -507,6 +507,21 @@ class TestServerMain:
finally:
self._stop_server(sock_path, t)
def test_unknown_command_is_a_clear_error_in_the_client(self, tmp_path):
"""The real client, against a server that does not know the command."""
from bmspy import client
sock_path = str(tmp_path / "server_refused.sock")
ready = threading.Event()
t = self._make_server_thread(sock_path, ready, threading.Event())
t.start()
ready.wait(timeout=2)
try:
with pytest.raises(client.DaemonError, match="daemon refused 'NEWER': unknown command: 'NEWER'"):
client.socket_comms(sock_path, {"command": "NEWER", "client": "test"})
finally:
self._stop_server(sock_path, t)
def test_devices_command_lists_configured_devices(self, tmp_path):
"""DEVICES names every configured device, through the real client."""
from bmspy import client