Merge NAPALM/napalm-device-types#132 (4.45.0) into feature/services-need-restart-lxc

This commit is contained in:
christianmanivong committed 2026-11-26 19:25:55 +01:00
commit a5275d4c4d
9 files changed
+299 -36

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
"""Contracts Proxmox VE 9.3 made worth having, kept neutral (NetOrk/netork#2728).
A guest identity that survives a changed ID, the expiry of the credential a
driver logs in with, and what a host's package manager did in the past: each a
shape every driver of its kind can fill, with the platform's own calls left to
the driver.
"""
from __future__ import annotations
import typing
from typing import get_type_hints
from napalm_device_types import (
CredentialExpiryDict,
CredentialExpiryMixin,
UpdateHistoryDict,
UpdateHistoryPackageDict,
UpdateMixin,
)
from napalm_device_types.models import VMDict
def test_a_vm_may_carry_an_identity_that_outlives_its_vmid():
assert "uid" in get_type_hints(VMDict)
assert "uid" in VMDict.__optional_keys__
def test_a_credential_expiry_names_the_credential_and_when_it_ends():
assert set(get_type_hints(CredentialExpiryDict)) == {"kind", "name", "expires"}
kinds = typing.get_args(get_type_hints(CredentialExpiryDict)["kind"])
assert set(kinds) == {"api-token", "account"}
def test_credential_expiry_is_a_contract_not_a_placeholder():
assert not hasattr(CredentialExpiryMixin, "get_credential_expiry")
def test_an_update_transaction_is_its_packages_and_who_asked_for_it():
assert set(get_type_hints(UpdateHistoryDict)) == {
"id",
"start",
"end",
"packages",
"requested_by",
"command",
"error",
}
assert set(get_type_hints(UpdateHistoryPackageDict)) == {
"name",
"action",
"old_version",
"new_version",
}
actions = typing.get_args(get_type_hints(UpdateHistoryPackageDict)["action"])
assert set(actions) == {
"install",
"reinstall",
"upgrade",
"downgrade",
"remove",
"purge",
"disappear",
}
def test_update_history_is_declared_next_to_pending_updates():
assert not hasattr(UpdateMixin, "get_update_history")