mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 20:31:27 -07:00
Ship constants to the modules via internal module params rather than a secondary dict.
This commit is contained in:
parent
a404d0ffe2
commit
186337db28
11 changed files with 42 additions and 39 deletions
|
@ -36,7 +36,6 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
|||
dict(
|
||||
ANSIBLE_MODULE_ARGS=dict(
|
||||
foo=False, bar=[1,2,3], bam="bam", baz=u'baz'),
|
||||
ANSIBLE_MODULE_CONSTANTS=dict()
|
||||
))):
|
||||
from ansible.module_utils import basic
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ empty_invocation = {u'module_args': {}}
|
|||
@unittest.skipIf(sys.version_info[0] >= 3, "Python 3 is not supported on targets (yet)")
|
||||
class TestAnsibleModuleExitJson(unittest.TestCase):
|
||||
def setUp(self):
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}))
|
||||
self.stdin_swap_ctx = swap_stdin_and_argv(stdin_data=args)
|
||||
self.stdin_swap_ctx.__enter__()
|
||||
|
||||
|
@ -120,7 +120,7 @@ class TestAnsibleModuleExitValuesRemoved(unittest.TestCase):
|
|||
def test_exit_json_removes_values(self):
|
||||
self.maxDiff = None
|
||||
for args, return_val, expected in self.dataset:
|
||||
params = dict(ANSIBLE_MODULE_ARGS=args, ANSIBLE_MODULE_CONSTANTS={})
|
||||
params = dict(ANSIBLE_MODULE_ARGS=args)
|
||||
params = json.dumps(params)
|
||||
|
||||
with swap_stdin_and_argv(stdin_data=params):
|
||||
|
@ -143,7 +143,7 @@ class TestAnsibleModuleExitValuesRemoved(unittest.TestCase):
|
|||
expected = copy.deepcopy(expected)
|
||||
del expected['changed']
|
||||
expected['failed'] = True
|
||||
params = dict(ANSIBLE_MODULE_ARGS=args, ANSIBLE_MODULE_CONSTANTS={})
|
||||
params = dict(ANSIBLE_MODULE_ARGS=args)
|
||||
params = json.dumps(params)
|
||||
with swap_stdin_and_argv(stdin_data=params):
|
||||
with swap_stdout():
|
||||
|
|
|
@ -43,7 +43,7 @@ except ImportError:
|
|||
|
||||
class TestAnsibleModuleSysLogSmokeTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}))
|
||||
|
||||
# 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)
|
||||
|
@ -80,7 +80,7 @@ class TestAnsibleModuleSysLogSmokeTest(unittest.TestCase):
|
|||
class TestAnsibleModuleJournaldSmokeTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}))
|
||||
|
||||
# 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)
|
||||
|
@ -129,7 +129,7 @@ class TestAnsibleModuleLogSyslog(unittest.TestCase):
|
|||
}
|
||||
|
||||
def setUp(self):
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}))
|
||||
# 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__()
|
||||
|
@ -190,7 +190,7 @@ class TestAnsibleModuleLogJournal(unittest.TestCase):
|
|||
|
||||
# overriding run lets us use context managers for setup/teardown-esque behavior
|
||||
def setUp(self):
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}))
|
||||
# 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__()
|
||||
|
|
|
@ -62,7 +62,7 @@ class TestAnsibleModuleRunCommand(unittest.TestCase):
|
|||
if path == '/inaccessible':
|
||||
raise OSError(errno.EPERM, "Permission denied: '/inaccessible'")
|
||||
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}))
|
||||
# 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__()
|
||||
|
|
|
@ -31,7 +31,7 @@ class TestAnsibleModuleExitJson(unittest.TestCase):
|
|||
def test_module_utils_basic_safe_eval(self):
|
||||
from ansible.module_utils import basic
|
||||
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={}))
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}))
|
||||
|
||||
with swap_stdin_and_argv(stdin_data=args):
|
||||
basic._ANSIBLE_ARGS = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue