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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user