Select the bmspy-ups device from the configured devices
bmspy-ups selected its device from the devices that had data at startup, and exited with status 0 if the selection failed. One failed first read ended the monitor or made it select the wrong device. The server has a new DEVICES command that lists the configured names, and client.list_devices calls it. bmspy-ups selects from that list and then waits for the first data of its device. A wrong or missing --device now exits with status 2. The service file does not restart on that status, because a restart cannot correct it. An older server ends on the unknown DEVICES command, so update the server first.
This commit is contained in:
@@ -445,6 +445,20 @@ class TestServerMain:
|
||||
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
|
||||
|
||||
sock_path = str(tmp_path / "server_devices.sock")
|
||||
ready = threading.Event()
|
||||
t = self._make_server_thread(sock_path, ready, threading.Event())
|
||||
t.start()
|
||||
ready.wait(timeout=2)
|
||||
try:
|
||||
assert client.list_devices(sock_path, "test") == ["ttyUSB0"]
|
||||
finally:
|
||||
self._stop_server(sock_path, t)
|
||||
|
||||
def test_deregister_command(self, tmp_path):
|
||||
"""Test DEREGISTER command via server main()."""
|
||||
sock_path = str(tmp_path / "server_dereg.sock")
|
||||
|
||||
Reference in New Issue
Block a user