summaryrefslogtreecommitdiff
path: root/test/units
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2016-05-13 10:03:16 -0700
committerToshio Kuratomi <a.badger@gmail.com>2016-05-13 10:03:16 -0700
commitc1cc9f1f231d8698453023a3b3160461c83c0533 (patch)
tree7bee0c1e8c0a981cf2fcbc5b38df00b6ecbc643c /test/units
parent28771960a1789e8d726e76d6de1194401bffc92c (diff)
parent186337db28f1111575bde9b2978de00364964578 (diff)
downloadansible-c1cc9f1f231d8698453023a3b3160461c83c0533.tar.gz
Merge pull request #15845 from abadger/ziploader-constants
Ship constants to the modules via internal module params rather than a secondary dict
Diffstat (limited to 'test/units')
-rw-r--r--test/units/module_utils/basic/test__log_invocation.py1
-rw-r--r--test/units/module_utils/basic/test_exit_json.py6
-rw-r--r--test/units/module_utils/basic/test_log.py8
-rw-r--r--test/units/module_utils/basic/test_run_command.py2
-rw-r--r--test/units/module_utils/basic/test_safe_eval.py2
-rw-r--r--test/units/module_utils/test_basic.py13
-rw-r--r--test/units/module_utils/test_distribution_version.py2
7 files changed, 16 insertions, 18 deletions
diff --git a/test/units/module_utils/basic/test__log_invocation.py b/test/units/module_utils/basic/test__log_invocation.py
index 677eaa2c90..d4510c5efc 100644
--- a/test/units/module_utils/basic/test__log_invocation.py
+++ b/test/units/module_utils/basic/test__log_invocation.py
@@ -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
diff --git a/test/units/module_utils/basic/test_exit_json.py b/test/units/module_utils/basic/test_exit_json.py
index 2cc6239845..e92f328ef2 100644
--- a/test/units/module_utils/basic/test_exit_json.py
+++ b/test/units/module_utils/basic/test_exit_json.py
@@ -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():
diff --git a/test/units/module_utils/basic/test_log.py b/test/units/module_utils/basic/test_log.py
index 6e47e46c00..c162504ca5 100644
--- a/test/units/module_utils/basic/test_log.py
+++ b/test/units/module_utils/basic/test_log.py
@@ -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__()
diff --git a/test/units/module_utils/basic/test_run_command.py b/test/units/module_utils/basic/test_run_command.py
index a78825d46b..35186e220e 100644
--- a/test/units/module_utils/basic/test_run_command.py
+++ b/test/units/module_utils/basic/test_run_command.py
@@ -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__()
diff --git a/test/units/module_utils/basic/test_safe_eval.py b/test/units/module_utils/basic/test_safe_eval.py
index cc2aaf8a53..393416c0fd 100644
--- a/test/units/module_utils/basic/test_safe_eval.py
+++ b/test/units/module_utils/basic/test_safe_eval.py
@@ -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
diff --git a/test/units/module_utils/test_basic.py b/test/units/module_utils/test_basic.py
index 42825ff304..d2025235bc 100644
--- a/test/units/module_utils/test_basic.py
+++ b/test/units/module_utils/test_basic.py
@@ -41,7 +41,7 @@ realimport = builtins.__import__
class TestModuleUtilsBasic(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__()
@@ -288,7 +288,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
req_to = (('bam', 'baz'),)
# should test ok
- args = json.dumps(dict(ANSIBLE_MODULE_ARGS={"foo": "hello"}, ANSIBLE_MODULE_CONSTANTS={}))
+ args = json.dumps(dict(ANSIBLE_MODULE_ARGS={"foo": "hello"}))
with swap_stdin_and_argv(stdin_data=args):
basic._ANSIBLE_ARGS = None
@@ -305,7 +305,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
# FIXME: add asserts here to verify the basic config
# 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={}))
with swap_stdin_and_argv(stdin_data=args):
basic._ANSIBLE_ARGS = None
@@ -322,7 +322,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
)
# 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"}))
with swap_stdin_and_argv(stdin_data=args):
self.assertRaises(
@@ -338,7 +338,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
)
# 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"}))
with swap_stdin_and_argv(stdin_data=args):
self.assertRaises(
@@ -550,14 +550,13 @@ class TestModuleUtilsBasic(unittest.TestCase):
from ansible.module_utils import basic
basic._ANSIBLE_ARGS = None
- args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}, ANSIBLE_MODULE_CONSTANTS={"SELINUX_SPECIAL_FS": "nfs,nfsd,foos"}))
+ args = json.dumps(dict(ANSIBLE_MODULE_ARGS={'_ansible_selinux_special_fs': "nfs,nfsd,foos"}))
with swap_stdin_and_argv(stdin_data=args):
am = basic.AnsibleModule(
argument_spec = dict(),
)
- print(am.constants)
def _mock_find_mount_point(path):
if path.startswith('/some/path'):
diff --git a/test/units/module_utils/test_distribution_version.py b/test/units/module_utils/test_distribution_version.py
index 3ade3b0c3a..1f9a767f03 100644
--- a/test/units/module_utils/test_distribution_version.py
+++ b/test/units/module_utils/test_distribution_version.py
@@ -400,7 +400,7 @@ def test_distribution_version():
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):
module = basic.AnsibleModule(argument_spec=dict())