Merge remote-tracking branch 'origin/main' into feat/lldp-agent-template
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m6s
driver / test (3.13) (pull_request) Successful in 1m6s
driver / test (3.12) (pull_request) Successful in 1m14s
driver / lowest (pull_request) Successful in 38s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Successful in 1m10s
CI / driver (pull_request) Successful in 2m45s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m6s
driver / test (3.13) (pull_request) Successful in 1m6s
driver / test (3.12) (pull_request) Successful in 1m14s
driver / lowest (pull_request) Successful in 38s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Successful in 1m10s
CI / driver (pull_request) Successful in 2m45s
driver / publish (pull_request) Skipped
# Conflicts: # CHANGELOG.md
This commit is contained in:
commit
51e8c849bb
11 files changed
+202
-65
No files matched your search
@@ -32,7 +32,7 @@
|
||||
},
|
||||
"mypy_relaxed": [],
|
||||
"python_file_lines": {
|
||||
"napalm_device_types/models.py": 1504
|
||||
"napalm_device_types/models.py": 1463
|
||||
},
|
||||
"untyped_public": []
|
||||
}
|
||||
@@ -22,7 +22,7 @@ from napalm_device_types import (
|
||||
|
||||
def test_a_profile_says_where_each_value_lives():
|
||||
assert set(get_type_hints(SnmpHealthProfile)) == {"uptime", "cpu", "memory", "interfaces"}
|
||||
assert set(get_type_hints(SnmpValueSpec)) == {"oids", "table", "fold", "pattern"}
|
||||
assert set(get_type_hints(SnmpValueSpec)) == {"oids", "table", "fold", "pattern", "unknown"}
|
||||
assert set(get_type_hints(SnmpMemorySpec)) == {"total", "used", "free", "percent", "unit"}
|
||||
assert set(get_type_hints(SnmpInterfacesSpec)) == {"skip", "tx_errors_are_drops"}
|
||||
|
||||
@@ -42,6 +42,24 @@ def test_a_driver_declares_its_profile_as_a_class_attribute():
|
||||
assert Driver.SNMP_HEALTH_PROFILE["cpu"]["oids"][0] == "1.3.6.1.4.1.9.1"
|
||||
|
||||
|
||||
def test_a_value_the_agent_gets_wrong_is_declared_unknown():
|
||||
"""Neither the standard reading nor a default: the application reports none."""
|
||||
assert get_type_hints(SnmpValueSpec)["unknown"] is bool
|
||||
|
||||
class Driver:
|
||||
SNMP_HEALTH_PROFILE: ClassVar[SnmpHealthProfile] = {"cpu": {"unknown": True}}
|
||||
|
||||
assert Driver.SNMP_HEALTH_PROFILE["cpu"].get("unknown") is True
|
||||
|
||||
|
||||
def test_the_shapes_live_in_their_own_module_and_models_still_exports_them():
|
||||
from napalm_device_types import models, snmp_health_profile
|
||||
|
||||
for name in ("SnmpHealthProfile", "SnmpValueSpec", "SnmpMemorySpec", "SnmpInterfacesSpec"):
|
||||
assert getattr(models, name) is getattr(snmp_health_profile, name), name
|
||||
assert getattr(snmp_health_profile, name).__module__ == snmp_health_profile.__name__
|
||||
|
||||
|
||||
def test_the_collector_in_the_base_package_warns_that_it_is_deprecated():
|
||||
async def get(oid):
|
||||
return None
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
"""A provisioning that failed after the hypervisor gave the VM its id says
|
||||
which VM it left behind, so the caller can remove it (NAPALM/napalm-proxmox#28)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pickle
|
||||
|
||||
import pytest
|
||||
|
||||
from napalm_device_types import VMProvisionIncomplete
|
||||
from napalm_device_types.provisioning import VMProvisionIncomplete as from_module
|
||||
|
||||
|
||||
def _raise_from(cause: Exception) -> VMProvisionIncomplete:
|
||||
try:
|
||||
try:
|
||||
raise cause
|
||||
except Exception as exc:
|
||||
raise VMProvisionIncomplete(str(exc), vmid="101", node="pve1") from exc
|
||||
except VMProvisionIncomplete as caught:
|
||||
return caught
|
||||
|
||||
|
||||
def test_it_is_exported_from_the_package_root():
|
||||
assert VMProvisionIncomplete is from_module
|
||||
|
||||
|
||||
def test_it_names_the_vm_left_behind():
|
||||
caught = _raise_from(RuntimeError("disk import failed"))
|
||||
assert (caught.vmid, caught.node) == ("101", "pve1")
|
||||
|
||||
|
||||
def test_it_keeps_the_failure_and_its_words():
|
||||
cause = RuntimeError("disk import failed")
|
||||
caught = _raise_from(cause)
|
||||
assert caught.__cause__ is cause
|
||||
assert str(caught) == "disk import failed"
|
||||
|
||||
|
||||
def test_a_caller_catching_runtime_error_still_catches_it():
|
||||
# The contract has create_vm_from_cloud_init raise RuntimeError on failure.
|
||||
with pytest.raises(RuntimeError):
|
||||
raise VMProvisionIncomplete("start failed", vmid="7", node="n")
|
||||
|
||||
|
||||
def test_vmid_and_node_are_keyword_only():
|
||||
with pytest.raises(TypeError):
|
||||
VMProvisionIncomplete("failed", "101", "pve1") # type: ignore[misc]
|
||||
|
||||
|
||||
def test_it_survives_pickling_as_a_task_result_would():
|
||||
caught = pickle.loads(pickle.dumps(VMProvisionIncomplete("failed", vmid="101", node="pve1")))
|
||||
assert (str(caught), caught.vmid, caught.node) == ("failed", "101", "pve1")
|
||||
Reference in new issue
Block a user