Merge branch 'fix/vm-resume-2658'
# Conflicts: # CHANGELOG.md
This commit is contained in:
commit
784f7ac686
3 files changed
+63
-2
No files matched your search
@@ -12,6 +12,7 @@ These tests pin the property that prevents a fourth.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import inspect
|
||||
|
||||
import pytest
|
||||
@@ -82,6 +83,7 @@ class TestDeclaredMethodsDoNotExistAtRuntime:
|
||||
(StorageDriver, "get_disks"),
|
||||
(StorageDriver, "get_volumes"),
|
||||
(HypervisorDriver, "get_vms"),
|
||||
(HypervisorDriver, "resume_vm"),
|
||||
(FirewallDriver, "send_wake_on_lan"),
|
||||
(SwitchDriver, "set_vlan"),
|
||||
(AccessPointDriver, "get_wireless_config"),
|
||||
@@ -101,6 +103,27 @@ class TestDeclaredMethodsDoNotExistAtRuntime:
|
||||
assert not hasattr(base, method)
|
||||
|
||||
|
||||
class TestHypervisorPowerContract:
|
||||
"""The power actions a hypervisor driver may implement, as declared."""
|
||||
|
||||
@staticmethod
|
||||
def _declared(module) -> dict[str, list[str]]:
|
||||
tree = ast.parse(inspect.getsource(module))
|
||||
methods: dict[str, list[str]] = {}
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.FunctionDef):
|
||||
methods[node.name] = [a.arg for a in node.args.args]
|
||||
return methods
|
||||
|
||||
def test_resume_vm_is_declared_beside_suspend_vm(self):
|
||||
"""A VM netOrk paused must be one it can bring back (NetOrk/netork#2658)."""
|
||||
from napalm_device_types import hypervisor
|
||||
|
||||
declared = self._declared(hypervisor)
|
||||
assert declared.get("suspend_vm") == ["self", "name"]
|
||||
assert declared.get("resume_vm") == ["self", "name"]
|
||||
|
||||
|
||||
class TestNoShadowingAcrossRoles:
|
||||
"""The regression test for the bug class."""
|
||||
|
||||
|
||||
Reference in new issue
Block a user