style: ruff format and the lint rules of the driver standard
Mechanical: ruff format, and ruff check --fix with the rule set every NAPALM driver uses (E, F, I, UP, B at line length 100, Python 3.10). Mapping and Iterable come from collections.abc, imports are sorted. What ruff cannot fix comes in the next commit.
This commit is contained in:
1 parent
5b24675a12
commit
09029ca0a4
29 files changed
+985
-456
No files matched your search
@@ -88,29 +88,33 @@ def test_ethernet_link_state(props, is_up, is_enabled):
|
||||
|
||||
def test_ethernet_unset_addresses_and_formats():
|
||||
# Supermicro and others report unset addresses as 0.0.0.0 or "::" and MACs in lower case.
|
||||
eth = parse_ethernet_interface({
|
||||
"Id": "1",
|
||||
"MACAddress": "0c:c4:7a:aa:bb:cc",
|
||||
"SpeedMbps": None,
|
||||
"IPv4Addresses": [
|
||||
{"Address": "0.0.0.0", "SubnetMask": "0.0.0.0"},
|
||||
{"Address": "10.1.2.3", "SubnetMask": "255.255.255.0"},
|
||||
{"Address": "10.1.2.4", "SubnetMask": "garbage"},
|
||||
{"Address": None},
|
||||
],
|
||||
"IPv6Addresses": [
|
||||
{"Address": "::", "PrefixLength": 0},
|
||||
{"Address": "2001:DB8::5", "PrefixLength": 64},
|
||||
{"Address": "2001:db8::6"},
|
||||
],
|
||||
})
|
||||
eth = parse_ethernet_interface(
|
||||
{
|
||||
"Id": "1",
|
||||
"MACAddress": "0c:c4:7a:aa:bb:cc",
|
||||
"SpeedMbps": None,
|
||||
"IPv4Addresses": [
|
||||
{"Address": "0.0.0.0", "SubnetMask": "0.0.0.0"},
|
||||
{"Address": "10.1.2.3", "SubnetMask": "255.255.255.0"},
|
||||
{"Address": "10.1.2.4", "SubnetMask": "garbage"},
|
||||
{"Address": None},
|
||||
],
|
||||
"IPv6Addresses": [
|
||||
{"Address": "::", "PrefixLength": 0},
|
||||
{"Address": "2001:DB8::5", "PrefixLength": 64},
|
||||
{"Address": "2001:db8::6"},
|
||||
],
|
||||
}
|
||||
)
|
||||
assert eth["interface"]["mac_address"] == "0C:C4:7A:AA:BB:CC"
|
||||
assert eth["interface"]["speed"] == -1.0
|
||||
assert eth["interface"]["mtu"] == 0
|
||||
assert eth["interface"]["description"] == ""
|
||||
assert eth["ipv4"] == {"10.1.2.3": {"prefix_length": 24}}
|
||||
assert eth["ipv6"] == {"2001:db8::5": {"prefix_length": 64},
|
||||
"2001:db8::6": {"prefix_length": 128}}
|
||||
assert eth["ipv6"] == {
|
||||
"2001:db8::5": {"prefix_length": 64},
|
||||
"2001:db8::6": {"prefix_length": 128},
|
||||
}
|
||||
|
||||
|
||||
# --- NetworkProtocol -----------------------------------------------------------------------
|
||||
@@ -133,7 +137,11 @@ def test_network_protocol(rackmount):
|
||||
}
|
||||
assert np["ntp"] == {"enabled": None, "servers": []}
|
||||
assert np["snmp"] == {
|
||||
"enabled": True, "port": 161, "v1": True, "v2c": False, "v3": True,
|
||||
"enabled": True,
|
||||
"port": 161,
|
||||
"v1": True,
|
||||
"v2c": False,
|
||||
"v3": True,
|
||||
"communities": [
|
||||
{"name": "Read-only community", "access": "Limited"},
|
||||
{"name": "Full access community", "access": "Full"},
|
||||
@@ -149,8 +157,14 @@ def test_network_protocol_ntp(telemetry):
|
||||
}
|
||||
assert np["protocols"]["NTP"] == {"enabled": True, "port": None}
|
||||
# Older SNMP schema: only ProtocolEnabled and Port.
|
||||
assert np["snmp"] == {"enabled": True, "port": 161, "v1": None, "v2c": None, "v3": None,
|
||||
"communities": []}
|
||||
assert np["snmp"] == {
|
||||
"enabled": True,
|
||||
"port": 161,
|
||||
"v1": None,
|
||||
"v2c": None,
|
||||
"v3": None,
|
||||
"communities": [],
|
||||
}
|
||||
|
||||
|
||||
def test_network_protocol_port_without_flag():
|
||||
@@ -162,5 +176,11 @@ def test_network_protocol_ntp_blank_entries():
|
||||
servers = ["", None, " pool.ntp.org ", "pool.ntp.org"]
|
||||
np = parse_network_protocol({"NTP": {"ProtocolEnabled": True, "NTPServers": servers}})
|
||||
assert np["ntp"]["servers"] == ["pool.ntp.org"]
|
||||
assert np["snmp"] == {"enabled": None, "port": None, "v1": None, "v2c": None, "v3": None,
|
||||
"communities": []}
|
||||
assert np["snmp"] == {
|
||||
"enabled": None,
|
||||
"port": None,
|
||||
"v1": None,
|
||||
"v2c": None,
|
||||
"v3": None,
|
||||
"communities": [],
|
||||
}
|
||||
Reference in new issue
Block a user