diff --git a/CHANGELOG.md b/CHANGELOG.md index c6ff2f0..f62e674 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ All notable changes to this driver. The format follows ## [Unreleased] ### Changed +- `load_replace_candidate` is `None` instead of a method that raises + `NotImplementedError`, so a caller that asks whether the driver can replace a + configuration gets no. netOrk offered a config restore for these devices that + could only fail (NetOrk/netork#2503). - **Breaking:** `get_playback_state()` and `get_zone_info()` return the shapes of napalm-device-types' media contract. `get_playback_state()` is `{"state": "playing"|"paused"|"stopped"|"transitioning", "source": "radio"|…}` diff --git a/README.md b/README.md index f545603..e3231a3 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,8 @@ speaker's connection, whatever its medium. ## Not supported -Configuration management (`load_replace_candidate` and `load_merge_candidate` raise -`NotImplementedError`), configuration export (`get_config`), the CLI (`cli`, NAPALM's +Configuration management (`load_replace_candidate` is `None`, `load_merge_candidate` +raises `NotImplementedError`), configuration export (`get_config`), the CLI (`cli`, NAPALM's stub), the interface addresses (`get_interfaces_ip`: the speaker reports no prefix length, and SoCo has no reading for one), and every routing, LLDP, ARP, MAC table, NTP, SNMP, BGP, optics, probe, user, network-instance, firewall-policy and environment getter. The driver leaves those getters to NAPALM, diff --git a/napalm_sonos/sonos_driver.py b/napalm_sonos/sonos_driver.py index dfaec2e..54d106e 100644 --- a/napalm_sonos/sonos_driver.py +++ b/napalm_sonos/sonos_driver.py @@ -191,9 +191,9 @@ class SonosDriver(MediaDriver): """Discard the candidate config (no-op on Sonos).""" pass - def load_replace_candidate(self, filename: str = "", config: str = "") -> None: - """Load a replacement config (not supported on Sonos).""" - raise NotImplementedError("Sonos does not support config replacement") + #: No config replace: switched off rather than a stub that raises, so asking + #: whether the driver has one says no (NetOrk/netork#2503). + load_replace_candidate = None # type: ignore[assignment] def load_merge_candidate(self, filename: str = "", config: str = "") -> None: """Load a merge candidate (not supported on Sonos).""" diff --git a/tests/test_config_replace.py b/tests/test_config_replace.py new file mode 100644 index 0000000..5918a44 --- /dev/null +++ b/tests/test_config_replace.py @@ -0,0 +1,17 @@ +"""The driver cannot replace a device's configuration, and says so by not having the method. + +A ``load_replace_candidate`` that only raises looks like a replace to anyone who asks +whether the driver has one: netOrk offered a config restore for these devices that +could only fail (NetOrk/netork#2503). ``None`` is how a driver switches off a method +it would otherwise inherit, the convention of napalm-device-types and netOrk's +capability checks. +""" + +from __future__ import annotations + +from napalm_sonos import SonosDriver + + +def test_the_driver_has_no_config_replace(): + assert SonosDriver.load_replace_candidate is None + assert not callable(getattr(SonosDriver, "load_replace_candidate", None))