fix(driver): leave the caller's optional_args unchanged

__init__ popped "port" out of the dict it was handed, so the caller's
own optional_args lost its port. The driver now works on a copy.

Closes #19
This commit is contained in:
Christian Manivong committed 2026-11-01 21:43:09 +01:00
1 parent d78a55dd1a
commit 45f5b65427
3 files changed
+14 -2

No files matched your search

+2
View File
@@ -17,6 +17,8 @@ recorded here; their history is the git log.
- `get_arp_table()` reports an unknown age as `-1.0` (napalm-device-types'
`ARP_AGE_UNKNOWN`) instead of `0.0`, which means "confirmed just now": neither
`ip neigh` nor `/proc/net/arp` has an age (NetOrk/netork#1327).
- The driver no longer removes `port` from the `optional_args` dict it is given:
the caller's dict stays as it was (#19).
## [0.7.0] - 2026-10-23
+2 -2
View File
@@ -109,8 +109,8 @@ class OpenWrtDriver(
self.timeout = timeout
self.device: ConnectHandler | None = None
if optional_args is None:
optional_args = {}
# A copy: the caller's dict stays as it was.
optional_args = dict(optional_args or {})
self.port = optional_args.pop("port", 22)
self.netmiko_optional_args = netmiko_args(optional_args)
+10
View File
@@ -1940,3 +1940,13 @@ class TestGetSystemConfigBridgeStp:
# Nothing to have an opinion about — distinct from "STP is off".
driver._send_command = _system_send(network_out="network.lan=interface\n")
assert driver.get_system_config()["bridge_stp"] is None
class TestOptionalArgs:
def test_the_callers_optional_args_are_left_as_they_were(self):
optional_args = {"port": 2222, "conn_timeout": 15}
drv = OpenWrtDriver("192.168.1.1", "root", "", optional_args=optional_args)
assert drv.port == 2222
assert optional_args == {"port": 2222, "conn_timeout": 15}