driver / standard (pull_request) Successful in 15s
driver / lint (pull_request) Successful in 12s
driver / types (pull_request) Successful in 1m0s
driver / test (3.12) (pull_request) Successful in 54s
driver / test (3.13) (pull_request) Successful in 51s
driver / lowest (pull_request) Successful in 27s
driver / build (pull_request) Successful in 25s
driver / security (pull_request) Successful in 1m2s
CI / driver (pull_request) Successful in 2m23s
driver / publish (pull_request) Skipped
The Smart driver's constructor wrote its connection defaults into the optional_args dict the caller passed in, and an unexpected connect error started with a German phrase. requirements.txt repeated pyproject's dependencies with floors older than the driver needs. The issue's other points were already fixed on main: pyproject declares napalm-device-types since34554eaand points its URLs at git.netork.io since10a3b1e. Closes #7
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
"""The Smart driver leaves the caller's optional_args alone and speaks English (#7)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
from napalm.base.exceptions import ConnectionException
|
|
|
|
from napalm_netgear.netgear_smart import NetgearSmartDriver
|
|
|
|
|
|
def test_the_callers_optional_args_are_not_changed():
|
|
args = {"port": 2222}
|
|
|
|
driver = NetgearSmartDriver("10.0.0.8", "admin", "pw", optional_args=args)
|
|
|
|
assert args == {"port": 2222}
|
|
assert driver.netmiko_optional_args["conn_timeout"] == 20
|
|
assert driver.netmiko_optional_args["banner_timeout"] == 20
|
|
assert driver.netmiko_optional_args["disabled_algorithms"] == {
|
|
"pubkeys": ["rsa-sha2-256", "rsa-sha2-512"]
|
|
}
|
|
|
|
|
|
def test_the_callers_own_values_still_win():
|
|
args = {"conn_timeout": 5, "disabled_algorithms": {}}
|
|
|
|
driver = NetgearSmartDriver("10.0.0.8", "admin", "pw", optional_args=args)
|
|
|
|
assert driver.netmiko_optional_args["conn_timeout"] == 5
|
|
assert driver.netmiko_optional_args["disabled_algorithms"] == {}
|
|
|
|
|
|
def test_an_unexpected_connect_error_is_reported_in_english():
|
|
driver = NetgearSmartDriver("10.0.0.8", "admin", "pw")
|
|
with patch(
|
|
"napalm_netgear.netgear_smart.ConnectHandler", side_effect=OSError("no route to host")
|
|
):
|
|
with pytest.raises(ConnectionException) as exc_info:
|
|
driver.open()
|
|
|
|
assert str(exc_info.value) == "Cannot connect to 10.0.0.8: no route to host"
|