fix(driver): load_replace_candidate is None, not a stub that raises (NetOrk/netork#2503) #33

Merged
christianmanivong merged 1 commits from fix/no-config-replace into main 2026-11-13 21:39:08 +00:00
5 changed files with 26 additions and 12 deletions

No files matched your search

+4
View File
@@ -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).
- Python 3.12 is the floor (`requires-python = ">=3.12"`): netOrk runs every driver
on 3.12, so 3.10 and 3.11 are no longer tested (NAPALM/driver-standard#6).
- The floor on napalm is 5.1: older releases import `pkg_resources`, which a Python
+2 -2
View File
@@ -54,8 +54,8 @@ has no Wi-Fi.
## Not supported
Configuration changes (`load_merge_candidate` and `load_replace_candidate` raise
`NotImplementedError`), `get_config`, LLDP, BGP, NTP, SNMP, users, routes, MAC address
Configuration changes (`load_replace_candidate` is `None`, `load_merge_candidate`
raises `NotImplementedError`), `get_config`, LLDP, BGP, NTP, SNMP, users, routes, MAC address
table, optics, environment, traceroute, VPN tunnels and the CLI.
`ping` returns an error and `SUPPORTS_PING` is `False`: the DAL accepts a `PINGTEST`
+3 -5
View File
@@ -614,11 +614,9 @@ class ZyxelVMGDriver(ResidentialGatewayDriver):
"""Not supported on Zyxel VMG."""
pass
def load_replace_candidate(
self, filename: str | None = None, config: str | None = None
) -> None:
"""Not supported on Zyxel VMG."""
raise NotImplementedError("Zyxel VMG does not support config replacement via NAPALM")
#: 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 | None = None, config: str | None = None) -> None:
"""Not supported on Zyxel VMG."""
+17
View File
@@ -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_zyxel import ZyxelVMGDriver
def test_the_driver_has_no_config_replace():
assert ZyxelVMGDriver.load_replace_candidate is None
assert not callable(getattr(ZyxelVMGDriver, "load_replace_candidate", None))
-5
View File
@@ -292,11 +292,6 @@ class TestZyxelVMGDriver:
assert not hasattr(type(self.driver), "run_device_action")
assert not hasattr(type(self.driver), "reboot")
def test_load_replace_candidate_raises(self):
self._setup_mocked_http()
with pytest.raises(NotImplementedError):
self.driver.load_replace_candidate()
def test_load_merge_candidate_raises(self):
self._setup_mocked_http()
with pytest.raises(NotImplementedError):