fix(driver): raise from getters instead of answering defaults
driver / standard (pull_request) Successful in 17s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m21s
driver / test (3.12) (pull_request) Successful in 3m44s
driver / test (3.13) (pull_request) Successful in 3m19s
driver / lowest (pull_request) Successful in 2m49s
driver / build (pull_request) Successful in 37s
driver / security (pull_request) Successful in 1m16s
CI / driver (pull_request) Successful in 5m32s
driver / publish (pull_request) Skipped

get_volume, get_mute, get_playback_state and get_current_track
answered 0, False, "STOPPED" and {} when the driver was not connected
or the read failed, so an unreachable speaker looked like a silent,
stopped one. They now raise ConnectionClosedException, or
ConnectionException / CommandErrorException with the SoCo error as
the cause.

get_playback_state called get_playback_state() on the SoCo object,
which SoCo does not have; the AttributeError was swallowed and every
speaker read as STOPPED. It now reads current_transport_state from
get_current_transport_info(). The tests mock the speaker with
MagicMock(spec=soco.SoCo), so a call to a method SoCo lacks fails.

Closes #9
This commit is contained in:
Christian Manivong committed 2026-11-02 08:38:28 +01:00
1 parent 8d5ed7e2c4
commit 15ba670a02
3 files changed
+116 -35

No files matched your search

+8
View File
@@ -18,6 +18,14 @@ All notable changes to this driver. The format follows
instead of returning as if the speaker had done it (#2).
- `get_arp_table()` takes NAPALM's `vrf` argument (#2).
- The driver module carries its docstring again (`__doc__` was `None`) (#2).
- `get_playback_state()` reports the speaker's real transport state (`PLAYING`,
`PAUSED_PLAYBACK`, `STOPPED`, `TRANSITIONING`); it called a method SoCo does not
have and answered `STOPPED` for every speaker (#9).
- `get_volume()`, `get_mute()`, `get_playback_state()` and `get_current_track()` raise
instead of answering `0`, `False`, `STOPPED` or `{}`: `ConnectionClosedException`
when the driver is not connected, `ConnectionException` when the speaker cannot be
reached, `CommandErrorException` when it refuses the request. An unreachable speaker
no longer reads as a silent, stopped one (#9).
## [0.3.0] - 2026-10-23