fix(driver): leave unsupported getters to NAPALM's stubs
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Successful in 17s
driver / types (pull_request) Successful in 1m0s
driver / test (3.13) (pull_request) Successful in 4m13s
driver / test (3.12) (pull_request) Successful in 4m15s
driver / lowest (pull_request) Successful in 3m42s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Successful in 5m38s
driver / publish (pull_request) Skipped
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Successful in 17s
driver / types (pull_request) Successful in 1m0s
driver / test (3.13) (pull_request) Successful in 4m13s
driver / test (3.12) (pull_request) Successful in 4m15s
driver / lowest (pull_request) Successful in 3m42s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Successful in 5m38s
driver / publish (pull_request) Skipped
get_config() overrode NAPALM's stub with `return {}` and took no
arguments, so get_config(retrieve="running") raised TypeError, which a
caller reports as a failed configuration backup on every poll. The
other getters a speaker has nothing for (environment, optics, routing,
ARP, MAC table, LLDP, NTP, SNMP, BGP, probes, users, network instances,
firewall policies) had the same shape: an empty answer reads as
"implemented, nothing there", and get_route_to() required an argument
NAPALM defaults.
All of them are gone; NAPALM's stubs raise NotImplementedError.
Closes #13
This commit is contained in:
1 parent
a86fb6cc3e
commit
56e0560eb2
4 files changed
+55
-84
No files matched your search
+43
-2
@@ -4,6 +4,7 @@ import pytest
|
||||
import requests
|
||||
import soco
|
||||
import soco.groups
|
||||
from napalm.base import NetworkDriver
|
||||
from napalm.base.exceptions import (
|
||||
CommandErrorException,
|
||||
ConnectionClosedException,
|
||||
@@ -334,8 +335,48 @@ def test_the_driver_module_has_its_docstring():
|
||||
assert module.__doc__ and "Sonos" in module.__doc__
|
||||
|
||||
|
||||
def test_get_arp_table_takes_napalms_vrf_argument():
|
||||
assert SonosDriver("192.168.1.100").get_arp_table(vrf="") == []
|
||||
#: NAPALM getters a speaker has nothing for. Each stays NAPALM's own stub, which raises
|
||||
#: NotImplementedError: an override answering {} or [] reads as "implemented, nothing
|
||||
#: there" to a caller that asks whether the driver has its own getter (#13).
|
||||
_NOT_SUPPORTED_GETTERS = [
|
||||
"get_arp_table",
|
||||
"get_bgp_config",
|
||||
"get_bgp_neighbors",
|
||||
"get_bgp_neighbors_detail",
|
||||
"get_config",
|
||||
"get_environment",
|
||||
"get_firewall_policies",
|
||||
"get_lldp_neighbors",
|
||||
"get_lldp_neighbors_detail",
|
||||
"get_mac_address_table",
|
||||
"get_network_instances",
|
||||
"get_ntp_peers",
|
||||
"get_ntp_servers",
|
||||
"get_ntp_stats",
|
||||
"get_optics",
|
||||
"get_probes_config",
|
||||
"get_probes_results",
|
||||
"get_route_to",
|
||||
"get_snmp_information",
|
||||
"get_users",
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("getter", _NOT_SUPPORTED_GETTERS)
|
||||
def test_an_unsupported_getter_is_napalms_stub(getter):
|
||||
assert getattr(SonosDriver, getter) is getattr(NetworkDriver, getter)
|
||||
|
||||
|
||||
def test_get_config_with_napalms_arguments_says_not_implemented():
|
||||
"""`get_config(retrieve="running")` raised TypeError, read as a failed backup (#13)."""
|
||||
with pytest.raises(NotImplementedError):
|
||||
SonosDriver("192.0.2.20").get_config(retrieve="running")
|
||||
|
||||
|
||||
def test_get_route_to_with_napalms_defaults_says_not_implemented():
|
||||
"""The override required `destination`; NAPALM's getter defaults it (#13)."""
|
||||
with pytest.raises(NotImplementedError):
|
||||
SonosDriver("192.0.2.20").get_route_to()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in new issue
Block a user