mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 10:25:28 +00:00
Merge pull request #114 from tyll/unittests
Cleanup/prepare unit tests for ethtool option support
This commit is contained in:
commit
b445c04ea7
2 changed files with 29 additions and 25 deletions
|
|
@ -486,13 +486,15 @@ class ArgValidator_DictEthernet(ArgValidatorDict):
|
|||
ArgValidatorNum(
|
||||
"speed", val_min=0, val_max=0xFFFFFFFF, default_value=0
|
||||
),
|
||||
ArgValidatorStr("duplex", enum_values=["half", "full"]),
|
||||
ArgValidatorStr(
|
||||
"duplex", enum_values=["half", "full"], default_value=None
|
||||
),
|
||||
],
|
||||
default_value=ArgValidator.MISSING,
|
||||
)
|
||||
|
||||
def get_default_ethernet(self):
|
||||
return {"autoneg": None, "speed": 0, "duplex": None}
|
||||
return dict([(k, v.default_value) for k, v in self.nested.items()])
|
||||
|
||||
def _validate_post(self, value, name, result):
|
||||
has_speed_or_duplex = result["speed"] != 0 or result["duplex"] is not None
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import sys
|
|||
import unittest
|
||||
|
||||
TESTS_BASEDIR = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(1, os.path.join(TESTS_BASEDIR, "..", "library"))
|
||||
sys.path.insert(1, os.path.join(TESTS_BASEDIR, "..", "module_utils"))
|
||||
sys.path.insert(1, os.path.join(TESTS_BASEDIR, "../..", "library"))
|
||||
sys.path.insert(1, os.path.join(TESTS_BASEDIR, "../..", "module_utils"))
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
|
|
@ -23,7 +23,7 @@ sys.modules["ansible.module_utils.basic"] = mock.Mock()
|
|||
sys.modules["ansible.module_utils"] = mock.Mock()
|
||||
sys.modules["ansible.module_utils.network_lsr"] = __import__("network_lsr")
|
||||
|
||||
# pylint: disable=import-error
|
||||
# pylint: disable=import-error, wrong-import-position
|
||||
import network_lsr
|
||||
import network_connections as n
|
||||
|
||||
|
|
@ -67,6 +67,8 @@ def pprint(msg, obj):
|
|||
ARGS_CONNECTIONS = network_lsr.argument_validator.ArgValidator_ListConnections()
|
||||
VALIDATE_ONE_MODE_INITSCRIPTS = ARGS_CONNECTIONS.VALIDATE_ONE_MODE_INITSCRIPTS
|
||||
|
||||
ETHERNET_DEFAULTS = {"autoneg": None, "duplex": None, "speed": 0}
|
||||
|
||||
|
||||
class TestValidator(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
@ -74,7 +76,7 @@ class TestValidator(unittest.TestCase):
|
|||
self.default_connection_settings = {
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"ignore_errors": None,
|
||||
"ip": {
|
||||
"gateway6": None,
|
||||
|
|
@ -313,7 +315,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "5",
|
||||
"ip": {
|
||||
|
|
@ -361,7 +363,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "5",
|
||||
|
|
@ -404,7 +406,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": False,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "5",
|
||||
|
|
@ -484,7 +486,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": None,
|
||||
|
|
@ -544,7 +546,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "prod1",
|
||||
|
|
@ -601,7 +603,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": None,
|
||||
|
|
@ -647,7 +649,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "prod.100",
|
||||
|
|
@ -736,7 +738,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": None,
|
||||
|
|
@ -782,7 +784,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "prod.100",
|
||||
|
|
@ -871,7 +873,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "eth0",
|
||||
|
|
@ -1059,7 +1061,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "bridge2",
|
||||
|
|
@ -1094,7 +1096,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "eth1",
|
||||
|
|
@ -1153,7 +1155,7 @@ class TestValidator(unittest.TestCase):
|
|||
"autoconnect": True,
|
||||
"bond": {"mode": "balance-rr", "miimon": None},
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "bond1",
|
||||
|
|
@ -1197,7 +1199,7 @@ class TestValidator(unittest.TestCase):
|
|||
"autoconnect": True,
|
||||
"bond": {"mode": "active-backup", "miimon": None},
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "bond1",
|
||||
|
|
@ -1252,7 +1254,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"ignore_errors": None,
|
||||
"interface_name": None,
|
||||
"ip": {
|
||||
|
|
@ -1363,7 +1365,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "6643-master",
|
||||
|
|
@ -1398,7 +1400,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "6643",
|
||||
|
|
@ -1592,7 +1594,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "555",
|
||||
|
|
@ -1682,7 +1684,7 @@ class TestValidator(unittest.TestCase):
|
|||
"actions": ["present", "up"],
|
||||
"autoconnect": True,
|
||||
"check_iface_exists": True,
|
||||
"ethernet": {"autoneg": None, "duplex": None, "speed": 0},
|
||||
"ethernet": ETHERNET_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"interface_name": "e556",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue