Speaker unreachable (requests' errors are OSErrors): ConnectionException; an error the speaker answers with (SoCoException, e.g. a UPnP fault): CommandErrorException. The SoCo error stays attached as __cause__.
get_playback_state() called get_playback_state() on the SoCo object, which SoCo (0.31.2, and the 0.30 floor) does not have; the AttributeError was swallowed and every speaker read as STOPPED. It now returns get_current_transport_info()["current_transport_state"].
The test speaker is now MagicMock(spec=soco.SoCo), so a call to a method SoCo lacks fails the test instead of being invented by the mock.
netOrk does not call these getters today, so nothing changes there.
Not in this PR
The wired-speaker detection (see #2) stays open: deviceProperties in SoCo is the UPnP DeviceProperties service, and none of its actions reports wired vs. wireless (GetZoneInfo returns serial, versions, IP, MAC, HTAudioIn, Flags, ExtraInfo); the only candidate, EthLink, is an evented variable that needs a UPnP event subscription. Renaming the attribute would still never report eth0. That needs a decision, written up separately.
Tests
Fixtures only (no speaker). Red first: the new tests for the transport state, the four not-connected cases and the failed reads failed against main; all pass now. pytest (42 passed), ruff format/check, mypy, napalm-standard ratchet green, coverage 78.8 % (floor 71).
## What
`get_volume()`, `get_mute()`, `get_playback_state()` and `get_current_track()` raise instead of answering defaults.
- Not connected: `ConnectionClosedException` (was `0` / `False` / `"STOPPED"` / `{}`).
- Speaker unreachable (`requests`' errors are `OSError`s): `ConnectionException`; an error the speaker answers with (`SoCoException`, e.g. a UPnP fault): `CommandErrorException`. The SoCo error stays attached as `__cause__`.
- `get_playback_state()` called `get_playback_state()` on the SoCo object, which SoCo (0.31.2, and the 0.30 floor) does not have; the `AttributeError` was swallowed and every speaker read as `STOPPED`. It now returns `get_current_transport_info()["current_transport_state"]`.
The test speaker is now `MagicMock(spec=soco.SoCo)`, so a call to a method SoCo lacks fails the test instead of being invented by the mock.
netOrk does not call these getters today, so nothing changes there.
## Not in this PR
The wired-speaker detection (see #2) stays open: `deviceProperties` in SoCo is the UPnP `DeviceProperties` service, and none of its actions reports wired vs. wireless (`GetZoneInfo` returns serial, versions, IP, MAC, `HTAudioIn`, `Flags`, `ExtraInfo`); the only candidate, `EthLink`, is an evented variable that needs a UPnP event subscription. Renaming the attribute would still never report `eth0`. That needs a decision, written up separately.
## Tests
Fixtures only (no speaker). Red first: the new tests for the transport state, the four not-connected cases and the failed reads failed against main; all pass now. pytest (42 passed), ruff format/check, mypy, `napalm-standard ratchet` green, coverage 78.8 % (floor 71).
Closes #9
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
get_volume(),get_mute(),get_playback_state()andget_current_track()raise instead of answering defaults.ConnectionClosedException(was0/False/"STOPPED"/{}).requests' errors areOSErrors):ConnectionException; an error the speaker answers with (SoCoException, e.g. a UPnP fault):CommandErrorException. The SoCo error stays attached as__cause__.get_playback_state()calledget_playback_state()on the SoCo object, which SoCo (0.31.2, and the 0.30 floor) does not have; theAttributeErrorwas swallowed and every speaker read asSTOPPED. It now returnsget_current_transport_info()["current_transport_state"].The test speaker is now
MagicMock(spec=soco.SoCo), so a call to a method SoCo lacks fails the test instead of being invented by the mock.netOrk does not call these getters today, so nothing changes there.
Not in this PR
The wired-speaker detection (see #2) stays open:
devicePropertiesin SoCo is the UPnPDevicePropertiesservice, and none of its actions reports wired vs. wireless (GetZoneInforeturns serial, versions, IP, MAC,HTAudioIn,Flags,ExtraInfo); the only candidate,EthLink, is an evented variable that needs a UPnP event subscription. Renaming the attribute would still never reporteth0. That needs a decision, written up separately.Tests
Fixtures only (no speaker). Red first: the new tests for the transport state, the four not-connected cases and the failed reads failed against main; all pass now. pytest (42 passed), ruff format/check, mypy,
napalm-standard ratchetgreen, coverage 78.8 % (floor 71).Closes #9
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