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). What ruff cannot fix comes in the next commit.
This commit is contained in:
1 parent
1f6859de08
commit
3b873d91fe
27 files changed
+195
-225
No files matched your search
+3
-2
@@ -2,11 +2,11 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
import pytest
|
||||
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Sample API payloads
|
||||
@@ -124,6 +124,7 @@ PVE_USERS = [
|
||||
# Driver fixture
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _build_mock_api(
|
||||
nodes=None,
|
||||
node_status=None,
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from napalm.base.exceptions import ConnectionException
|
||||
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
from tests.conftest import _build_mock_api, NODES_LIST
|
||||
from tests.conftest import _build_mock_api
|
||||
|
||||
|
||||
class TestOpen:
|
||||
@@ -101,9 +102,7 @@ def _open_with(hostname, **api_kwargs):
|
||||
|
||||
class TestClusterNodeResolution:
|
||||
def test_local_node_wins_over_first_listed(self):
|
||||
drv = _open_with(
|
||||
"172.22.8.120", nodes=CLUSTER_NODES_LIST, cluster_status=CLUSTER_STATUS
|
||||
)
|
||||
drv = _open_with("172.22.8.120", nodes=CLUSTER_NODES_LIST, cluster_status=CLUSTER_STATUS)
|
||||
assert drv._node_name == "pve-dual"
|
||||
|
||||
def test_matches_by_ip_without_local_flag(self):
|
||||
@@ -118,9 +117,7 @@ class TestClusterNodeResolution:
|
||||
|
||||
def test_matches_short_name_of_fqdn(self):
|
||||
status = [{**n, "local": 0} for n in CLUSTER_STATUS if n["type"] == "node"]
|
||||
drv = _open_with(
|
||||
"pve-01.mgmt.example.com", nodes=CLUSTER_NODES_LIST, cluster_status=status
|
||||
)
|
||||
drv = _open_with("pve-01.mgmt.example.com", nodes=CLUSTER_NODES_LIST, cluster_status=status)
|
||||
assert drv._node_name == "pve-01"
|
||||
|
||||
def test_single_node_without_cluster_status(self):
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from tests.conftest import _build_mock_api, NODE_STATUS
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
from tests.conftest import _build_mock_api
|
||||
|
||||
|
||||
class TestGetEnvironment:
|
||||
@@ -25,9 +26,6 @@ class TestGetEnvironment:
|
||||
assert isinstance(result["fans"], dict)
|
||||
|
||||
def test_temperature_with_sensors(self):
|
||||
from tests.conftest import _build_mock_api, NODE_STATUS
|
||||
from unittest.mock import patch
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
|
||||
sensors_data = [
|
||||
{"name": "CPU Package", "value": "55.0"},
|
||||
@@ -49,9 +47,6 @@ class TestGetEnvironment:
|
||||
assert result["temperature"]["GPU Core"]["is_critical"] is False
|
||||
|
||||
def test_temperature_critical(self):
|
||||
from tests.conftest import _build_mock_api
|
||||
from unittest.mock import patch
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
|
||||
sensors_data = [{"name": "NVMe", "value": "98.0"}]
|
||||
mock_api = _build_mock_api(sensors=sensors_data)
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from tests.conftest import _build_mock_api, NODE_NETWORK
|
||||
from unittest.mock import patch
|
||||
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
from tests.conftest import NODE_NETWORK
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from tests.conftest import _build_mock_api, NODE_NETWORK
|
||||
from unittest.mock import patch
|
||||
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
from tests.conftest import NODE_NETWORK
|
||||
|
||||
|
||||
class TestGetInterfaces:
|
||||
@@ -89,10 +85,18 @@ class TestGetInterfacesCounters:
|
||||
result = driver.get_interfaces_counters()
|
||||
eth0 = result["eth0"]
|
||||
for field in (
|
||||
"tx_errors", "rx_errors", "tx_discards", "rx_discards",
|
||||
"tx_octets", "rx_octets", "tx_unicast_packets", "rx_unicast_packets",
|
||||
"tx_multicast_packets", "rx_multicast_packets",
|
||||
"tx_broadcast_packets", "rx_broadcast_packets",
|
||||
"tx_errors",
|
||||
"rx_errors",
|
||||
"tx_discards",
|
||||
"rx_discards",
|
||||
"tx_octets",
|
||||
"rx_octets",
|
||||
"tx_unicast_packets",
|
||||
"rx_unicast_packets",
|
||||
"tx_multicast_packets",
|
||||
"rx_multicast_packets",
|
||||
"tx_broadcast_packets",
|
||||
"rx_broadcast_packets",
|
||||
):
|
||||
assert field in eth0, f"Missing field: {field}"
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ import gzip
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from napalm_device_types import KernelFactsMixin
|
||||
from napalm_device_types.kernel import KERNEL_FACTS_COMMAND
|
||||
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
|
||||
REPORT = (
|
||||
|
||||
@@ -58,5 +58,8 @@ def test_an_unreadable_subscription_reports_nothing():
|
||||
def test_no_warnings_of_its_own():
|
||||
"""lldpd, the updates and the subscription are facts the caller reads
|
||||
(get_packages, get_available_updates, get_licenses)."""
|
||||
assert not any("get_device_warnings" in vars(c) for c in ProxmoxDriver.__mro__[:-1]
|
||||
if c.__module__.startswith("napalm_proxmox"))
|
||||
assert not any(
|
||||
"get_device_warnings" in vars(c)
|
||||
for c in ProxmoxDriver.__mro__[:-1]
|
||||
if c.__module__.startswith("napalm_proxmox")
|
||||
)
|
||||
@@ -11,6 +11,7 @@ from __future__ import annotations
|
||||
from unittest.mock import patch
|
||||
|
||||
from napalm_device_types import ListeningSocketsMixin
|
||||
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
|
||||
WIRE = (
|
||||
|
||||
+2
-1
@@ -2,8 +2,9 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
|
||||
class TestGetNTPServers:
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
|
||||
from napalm_proxmox import utils
|
||||
|
||||
|
||||
PROC_NET_ARP = """\
|
||||
IP address HW type Flags HW address Mask Device
|
||||
10.0.0.254 0x1 0x2 aa:bb:cc:dd:ee:ff * eth0
|
||||
@@ -137,10 +135,7 @@ class TestGetMACAddressTable:
|
||||
"cc:dd:ee:ff:00:11 dev eth0 vlan 20 master vmbr0\n"
|
||||
)
|
||||
|
||||
OVS_APPCTL = (
|
||||
" LOCAL 0 aa:bb:cc:dd:ee:03 0\n"
|
||||
" 1 10 11:22:33:44:55:66 100\n"
|
||||
)
|
||||
OVS_APPCTL = " LOCAL 0 aa:bb:cc:dd:ee:03 0\n 1 10 11:22:33:44:55:66 100\n"
|
||||
|
||||
def test_linux_bridge_entries(self, driver):
|
||||
def _exec(cmd):
|
||||
|
||||
+2
-3
@@ -2,8 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from tests.conftest import _build_mock_api, SDN_ZONES, SDN_VNETS
|
||||
from tests.conftest import _build_mock_api
|
||||
|
||||
|
||||
class TestGetVlans:
|
||||
@@ -52,8 +51,8 @@ class TestGetVlans:
|
||||
|
||||
def test_empty_sdn_returns_dict(self):
|
||||
from unittest.mock import patch
|
||||
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
from tests.conftest import _build_mock_api
|
||||
|
||||
mock_api = _build_mock_api(sdn_vnets=[], sdn_zones=[])
|
||||
drv = ProxmoxDriver("pve1", "root", "secret", optional_args={"verify_ssl": False})
|
||||
|
||||
@@ -11,9 +11,9 @@ from __future__ import annotations
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from napalm_device_types import ServicePackagesMixin
|
||||
from napalm_device_types.service_packages import SERVICE_PACKAGES_COMMAND
|
||||
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
|
||||
WIRE = (
|
||||
|
||||
@@ -9,6 +9,7 @@ from __future__ import annotations
|
||||
from unittest.mock import patch
|
||||
|
||||
from napalm_device_types import SYSTEM_IDENTITY_COMMAND, SystemIdentityMixin
|
||||
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
|
||||
# pve-dual, a Supermicro X10DRL-i: the product serial is the board vendor's default.
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from napalm_proxmox import utils
|
||||
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock, patch
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
from napalm_proxmox.vm_provision_mixin import ProxmoxVMProvisionMixin
|
||||
|
||||
from napalm_proxmox.vm_provision_mixin import ProxmoxVMProvisionMixin
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
Reference in new issue
Block a user