|
|
@ -31,8 +31,7 @@ try:
|
|
|
|
except ImportError:
|
|
|
|
except ImportError:
|
|
|
|
import __builtin__ as builtins
|
|
|
|
import __builtin__ as builtins
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.compat.six import PY3
|
|
|
|
from units.mock.procenv import swap_stdin_and_argv
|
|
|
|
from ansible.utils.unicode import to_bytes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.compat.tests import unittest
|
|
|
|
from ansible.compat.tests import unittest
|
|
|
|
from ansible.compat.tests.mock import patch, MagicMock, mock_open, Mock, call
|
|
|
|
from ansible.compat.tests.mock import patch, MagicMock, mock_open, Mock, call
|
|
|
@ -42,10 +41,14 @@ realimport = builtins.__import__
|
|
|
|
class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
def setUp(self):
|
|
|
|
self.real_stdin = sys.stdin
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
# unittest doesn't have a clean place to use a context manager, so we have to enter/exit manually
|
|
|
|
|
|
|
|
self.stdin_swap = swap_stdin_and_argv(stdin_data=args)
|
|
|
|
|
|
|
|
self.stdin_swap.__enter__()
|
|
|
|
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
def tearDown(self):
|
|
|
|
sys.stdin = self.real_stdin
|
|
|
|
# unittest doesn't have a clean place to use a context manager, so we have to enter/exit manually
|
|
|
|
|
|
|
|
self.stdin_swap.__exit__(None, None, None)
|
|
|
|
|
|
|
|
|
|
|
|
def clear_modules(self, mods):
|
|
|
|
def clear_modules(self, mods):
|
|
|
|
for mod in mods:
|
|
|
|
for mod in mods:
|
|
|
@ -271,13 +274,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_creation(self):
|
|
|
|
def test_module_utils_basic_ansible_module_creation(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec=dict(),
|
|
|
|
argument_spec=dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -293,12 +289,8 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
# should test ok
|
|
|
|
# should test ok
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={"foo": "hello"}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={"foo": "hello"}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with swap_stdin_and_argv(stdin_data=args):
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = arg_spec,
|
|
|
|
argument_spec = arg_spec,
|
|
|
|
mutually_exclusive = mut_ex,
|
|
|
|
mutually_exclusive = mut_ex,
|
|
|
@ -313,12 +305,8 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
# fail, because a required param was not specified
|
|
|
|
# fail, because a required param was not specified
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with swap_stdin_and_argv(stdin_data=args):
|
|
|
|
self.assertRaises(
|
|
|
|
self.assertRaises(
|
|
|
|
SystemExit,
|
|
|
|
SystemExit,
|
|
|
|
basic.AnsibleModule,
|
|
|
|
basic.AnsibleModule,
|
|
|
@ -333,12 +321,8 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
# fail because of mutually exclusive parameters
|
|
|
|
# fail because of mutually exclusive parameters
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={"foo":"hello", "bar": "bad", "bam": "bad"}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={"foo":"hello", "bar": "bad", "bam": "bad"}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with swap_stdin_and_argv(stdin_data=args):
|
|
|
|
self.assertRaises(
|
|
|
|
self.assertRaises(
|
|
|
|
SystemExit,
|
|
|
|
SystemExit,
|
|
|
|
basic.AnsibleModule,
|
|
|
|
basic.AnsibleModule,
|
|
|
@ -353,12 +337,8 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
# fail because a param required due to another param was not specified
|
|
|
|
# fail because a param required due to another param was not specified
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={"bam": "bad"}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={"bam": "bad"}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with swap_stdin_and_argv(stdin_data=args):
|
|
|
|
self.assertRaises(
|
|
|
|
self.assertRaises(
|
|
|
|
SystemExit,
|
|
|
|
SystemExit,
|
|
|
|
basic.AnsibleModule,
|
|
|
|
basic.AnsibleModule,
|
|
|
@ -374,13 +354,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_load_file_common_arguments(self):
|
|
|
|
def test_module_utils_basic_ansible_module_load_file_common_arguments(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -429,13 +402,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_selinux_mls_enabled(self):
|
|
|
|
def test_module_utils_basic_ansible_module_selinux_mls_enabled(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -455,13 +421,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_selinux_initial_context(self):
|
|
|
|
def test_module_utils_basic_ansible_module_selinux_initial_context(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -475,13 +434,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_selinux_enabled(self):
|
|
|
|
def test_module_utils_basic_ansible_module_selinux_enabled(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -513,13 +465,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_selinux_default_context(self):
|
|
|
|
def test_module_utils_basic_ansible_module_selinux_default_context(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -555,13 +500,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_selinux_context(self):
|
|
|
|
def test_module_utils_basic_ansible_module_selinux_context(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -604,11 +542,8 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={"SELINUX_SPECIAL_FS": "nfs,nfsd,foos"}))
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={"SELINUX_SPECIAL_FS": "nfs,nfsd,foos"}))
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
with swap_stdin_and_argv(stdin_data=args):
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
@ -650,13 +585,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_to_filesystem_str(self):
|
|
|
|
def test_module_utils_basic_ansible_module_to_filesystem_str(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -667,13 +595,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_user_and_group(self):
|
|
|
|
def test_module_utils_basic_ansible_module_user_and_group(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -688,13 +609,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_find_mount_point(self):
|
|
|
|
def test_module_utils_basic_ansible_module_find_mount_point(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -718,13 +632,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_set_context_if_different(self):
|
|
|
|
def test_module_utils_basic_ansible_module_set_context_if_different(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -769,13 +676,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_set_owner_if_different(self):
|
|
|
|
def test_module_utils_basic_ansible_module_set_owner_if_different(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -814,13 +714,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_set_group_if_different(self):
|
|
|
|
def test_module_utils_basic_ansible_module_set_group_if_different(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -859,13 +752,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
def test_module_utils_basic_ansible_module_set_mode_if_different(self):
|
|
|
|
def test_module_utils_basic_ansible_module_set_mode_if_different(self):
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -953,13 +839,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -1137,13 +1016,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
|
|
|
|
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
|
|
|
|
|
|
|
if PY3:
|
|
|
|
|
|
|
|
sys.stdin = StringIO(args)
|
|
|
|
|
|
|
|
sys.stdin.buffer = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
sys.stdin = BytesIO(to_bytes(args))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
am = basic.AnsibleModule(
|
|
|
|
argument_spec = dict(),
|
|
|
|
argument_spec = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|