summaryrefslogtreecommitdiffstats
path: root/test/units/module_utils
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2024-05-16 00:19:14 +0200
committerGitHub <noreply@github.com>2024-05-16 00:19:14 +0200
commit7e0a476ba25ae66940edf9bf99c0ab75c9bbb7d1 (patch)
tree149771589c65f80d31622315ee0b7af51916ced5 /test/units/module_utils
parentRefactor dmidecode fact gathering code (#83211) (diff)
downloadansible-7e0a476ba25ae66940edf9bf99c0ab75c9bbb7d1.tar.xz
ansible-7e0a476ba25ae66940edf9bf99c0ab75c9bbb7d1.zip
setup module, make missing sysctl minor issue (#81297)
Signed-off-by: Brian Coca <brian.coca+git@gmail.com> Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua> Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
Diffstat (limited to 'test/units/module_utils')
-rw-r--r--test/units/module_utils/facts/network/test_fc_wwn.py42
-rw-r--r--test/units/module_utils/facts/network/test_generic_bsd.py12
-rw-r--r--test/units/module_utils/facts/network/test_iscsi_get_initiator.py4
3 files changed, 26 insertions, 32 deletions
diff --git a/test/units/module_utils/facts/network/test_fc_wwn.py b/test/units/module_utils/facts/network/test_fc_wwn.py
index 3f91654fec..3f4bd9a96b 100644
--- a/test/units/module_utils/facts/network/test_fc_wwn.py
+++ b/test/units/module_utils/facts/network/test_fc_wwn.py
@@ -89,34 +89,28 @@ FCMSUTIL_OUT = """
"""
-def mock_get_bin_path(cmd, required=False, opt_dirs=None):
- result = None
- if cmd == 'lsdev':
- result = '/usr/sbin/lsdev'
- elif cmd == 'lscfg':
- result = '/usr/sbin/lscfg'
- elif cmd == 'fcinfo':
- result = '/usr/sbin/fcinfo'
- elif cmd == 'ioscan':
- result = '/usr/bin/ioscan'
- elif cmd == 'fcmsutil':
- result = '/opt/fcms/bin/fcmsutil'
- return result
+def mock_get_bin_path(cmd, required=False, opt_dirs=None, warning=None):
+ cmds = {
+ 'lsdev': '/usr/sbin/lsdev',
+ 'lscfg': '/usr/sbin/lscfg',
+ 'fcinfo': '/usr/sbin/fcinfo',
+ 'ioscan': '/usr/bin/ioscan',
+ 'fcmsutil': '/opt/fcms/bin/fcmsutil',
+ }
+ return cmds.get(cmd, None)
def mock_run_command(cmd):
rc = 0
- if 'lsdev' in cmd:
- result = LSDEV_OUTPUT
- elif 'lscfg' in cmd:
- result = LSCFG_OUTPUT
- elif 'fcinfo' in cmd:
- result = FCINFO_OUTPUT
- elif 'ioscan' in cmd:
- result = IOSCAN_OUT
- elif 'fcmsutil' in cmd:
- result = FCMSUTIL_OUT
- else:
+ COMMANDS = {
+ '/usr/sbin/lsdev': LSDEV_OUTPUT,
+ '/usr/sbin/lscfg': LSCFG_OUTPUT,
+ '/usr/sbin/fcinfo': FCINFO_OUTPUT,
+ '/usr/bin/ioscan': IOSCAN_OUT,
+ '/opt/fcms/bin/fcmsutil': FCMSUTIL_OUT,
+ }
+ result = COMMANDS.get(cmd.split()[0])
+ if result is None:
rc = 1
result = 'Error'
return (rc, result, '')
diff --git a/test/units/module_utils/facts/network/test_generic_bsd.py b/test/units/module_utils/facts/network/test_generic_bsd.py
index 4e4061dbb7..ee104c38e5 100644
--- a/test/units/module_utils/facts/network/test_generic_bsd.py
+++ b/test/units/module_utils/facts/network/test_generic_bsd.py
@@ -22,12 +22,12 @@ import unittest
from ansible.module_utils.facts.network import generic_bsd
-def get_bin_path(command):
- if command == 'ifconfig':
- return 'fake/ifconfig'
- elif command == 'route':
- return 'fake/route'
- return None
+def get_bin_path(command, warning=None):
+ cmds = {
+ 'ifconfig': 'fake/ifconfig',
+ 'route': 'fake/route',
+ }
+ return cmds.get(command, None)
netbsd_ifconfig_a_out_7_1 = r'''
diff --git a/test/units/module_utils/facts/network/test_iscsi_get_initiator.py b/test/units/module_utils/facts/network/test_iscsi_get_initiator.py
index 48f97b38fa..16ec7d9517 100644
--- a/test/units/module_utils/facts/network/test_iscsi_get_initiator.py
+++ b/test/units/module_utils/facts/network/test_iscsi_get_initiator.py
@@ -41,13 +41,13 @@ def test_get_iscsi_info(mocker):
inst = iscsi.IscsiInitiatorNetworkCollector()
mocker.patch('sys.platform', 'aix6')
- mocker.patch('ansible.module_utils.facts.network.iscsi.get_bin_path', return_value='/usr/sbin/lsattr')
+ mocker.patch.object(module, 'get_bin_path', return_value='/usr/sbin/lsattr')
mocker.patch.object(module, 'run_command', return_value=(0, LSATTR_OUTPUT, ''))
aix_iscsi_expected = {"iscsi_iqn": "iqn.localhost.hostid.7f000002"}
assert aix_iscsi_expected == inst.collect(module=module)
mocker.patch('sys.platform', 'hp-ux')
- mocker.patch('ansible.module_utils.facts.network.iscsi.get_bin_path', return_value='/opt/iscsi/bin/iscsiutil')
+ mocker.patch.object(module, 'get_bin_path', return_value='/opt/iscsi/bin/iscsiutil')
mocker.patch.object(module, 'run_command', return_value=(0, ISCSIUTIL_OUTPUT, ''))
hpux_iscsi_expected = {"iscsi_iqn": " iqn.2001-04.com.hp.stor:svcio"}
assert hpux_iscsi_expected == inst.collect(module=module)