summaryrefslogtreecommitdiff
path: root/test/units/module_utils/basic/test_exit_json.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix unit tests on Python 3.10.Matt Clay2021-05-071-0/+2
|
* Deprecate Py2.6 support for target nodes (#74165)Matt Martz2021-04-161-6/+17
|
* Support datetime.date object in module result (#70595)jabdr2020-07-141-0/+6
| | | | | | | * Support datetime.date object in module result Fixes #70583 * change blank lines for pep8 sanity test
* Clean up unit test boilerplate.Matt Clay2020-06-221-1/+1
|
* Add some more unittests for fail_jsonToshio Kuratomi2020-04-081-1/+22
| | | | Test that order of msg as a keyword arg doesn't matter
* Allow the msg argument to fail_json() to be a positional argumentToshio Kuratomi2020-04-081-2/+14
| | | | | | | | | | | | | fial_json() requires a message be given to it to inform the end user of why the module failed. Prior to this commit, the message had to be a keyword argument: module.fail_json(msg='Failed due to error') Since this is a required parameter, this commit allows the message to be given as a positional argument instead: module.fail_json('Failed due to an error')
* Split basic units (#33510)Toshio Kuratomi2017-12-181-4/+2
| | | | | | | | | | | | | | | Split the one monolithic test for basic.py into several files * Split test_basic.py along categories. This is preliminary to get a handle on things. Eventually we may want to further split it so each file is only testing a single function. * Cleanup unused imports from splitting test_basic.py * Port atomic_move test to pytest. Working on getting rid of need to maintain procenv * Split a test of symbolic_mode_to_octal to follow unittest best practices Each test should only invoke the function under test once * Port test_argument_spec to pytest. * Fix suboptions failure
* Porting tests to pytest (#33387)Toshio Kuratomi2017-12-051-125/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Porting tests to pytest * Achievement Get: No longer need mock/generator.py * Now done via pytest's parametrization * Port safe_eval to pytest * Port text tests to pytest * Port test_set_mode_if_different to pytest * Change conftest AnsibleModule fixtures to be more flexible * Move the AnsibleModules fixtures to module_utils/conftest.py for sharing * Testing the argspec code requires: * injecting both the argspec and the arguments. * Patching the arguments into sys.stdin at a different level * More porting to obsolete mock/procenv.py * Port run_command to pytest * Port known_hosts tests to pytest * Port safe_eval to pytest * Port test_distribution_version.py to pytest * Port test_log to pytest * Port test__log_invocation to pytest * Remove unneeded import of procenv in test_postgresql * Port test_pip to pytest style * As part of this, create a pytest ansiblemodule fixture in modules/conftest.py. This is slightly different than the approach taken in module_utils because here we need to override the AnsibleModule that the modules will inherit from instead of one that we're instantiating ourselves. * Fixup usage of parametrization in test_deprecate_warn * Check that the pip module failed in our test
* better backwards compat handling of statusBrian Coca2017-07-051-6/+6
| | | | | | | | restored 'rc' inspection but only when failed is not specified removed redundant changed from basic.py as task_executor already adds removed redundant filters, they are tests added aliases to tests removed from filters fixed test to new rc handling
* Ensure exit_json returns failed = FalseDag Wieers2017-05-301-2/+1
| | | | | | | | | | | This is required for modules that may return a non-zero `rc` value for a successful run, similar to #24865 for Windows fixing **win_chocolatey**. We also disable the dependency on `rc` value only, even if `failed` was set. Adapted unit and integration tests to the new scheme. Updated raw, shell, script, expect to take `rc` into account.
* test/: PEP8 compliancy (#24803)Dag Wieers2017-05-301-30/+34
| | | | | | | | | | * test/: PEP8 compliancy - Make PEP8 compliant * Python3 chokes on casting int to bytes (#24952) But if we tell the formatter that the var is a number, it works
* PEP 8 indent cleanup. (#20800)Matt Clay2017-01-291-4/+4
| | | | | | | | * PEP 8 E121 cleanup. * PEP 8 E126 cleanup. * PEP 8 E122 cleanup.
* Enable most unittests on python3 (just some vault unittests and a logging ↵Toshio Kuratomi2016-08-251-2/+0
| | | | | | | | | | one left) (#17240) Make some python3 fixes to make the unittests pass: * galaxy imports * dictionary iteration in role requirements * swap_stdout helper for unittests * Normalize to text string in a facts.py function
* Ship constants to the modules via internal module params rather than a ↵Toshio Kuratomi2016-05-121-3/+3
| | | | secondary dict.
* Remove reload from arg related tests. Changes to how ziploader passes args ↵Toshio Kuratomi2016-05-101-5/+3
| | | | mean we don't need reload anymore. (#15782)
* Allow AnsibleModules to be instantiated more than once in a moduleToshio Kuratomi2016-04-231-0/+3
| | | | Fix SELINUX monkeypatch in test_basic
* add _load_params debug overrides for module args/file passed on cmdlinenitzmahone2016-04-181-62/+35
| | | | | | Updated python module wrapper explode method to drop 'args' file next to module. Both execute() and excommunicate() debug methods now pass the module args via file to enable debuggers that are picky about stdin. Updated unit tests to use a context manager for masking/restoring default streams and argv.
* Fix unittestsToshio Kuratomi2016-04-121-11/+34
|
* ZiploaderToshio Kuratomi2016-04-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Ziploader proof of concept (jimi-c) * Cleanups to proof of concept ziploader branch: * python3 compatible base64 encoding * zipfile compression (still need to enable toggling this off for systems without zlib support in python) * Allow non-wildcard imports (still need to make this recusrsive so that we can have module_utils code that imports other module_utils code.) * Better tracebacks: module filename is kept and module_utils directory is kept so that tracebacks show the real filenames that the errors appear in. * Make sure we import modules that are used into the module_utils files that they are used in. * Set ansible version in a more pythonic way for ziploader than we were doing in module replacer * Make it possible to set the module compression as an inventory var This may be necessary on systems where python has been compiled without zlib compression. * Refactoring of module_common code: * module replacer only replaces values that make sense for that type of file (example: don't attempt to replace python imports if we're in a powershell module). * Implement configurable shebang support for ziploader wrapper * Implement client-side constants (for SELINUX_SPECIAL_FS and SYSLOG) via environment variable. * Remove strip_comments param as we're never going to use it (ruins line numbering) * Don't repeat ourselves about detecting REPLACER * Add an easy way to debug * Port test-module to the ziploader-aware modify_module() * strip comments and blank lines from the wrapper so we send less over the wire. * Comments cleanup * Remember to output write the module line itself in powershell modules * for line in lines strips the newlines so we have to add them back in
* Use io.StringIO and io.BytesIO instead of StringIO.StringIO for compat with py3Toshio Kuratomi2016-02-261-4/+4
|
* fixed tests to follow new invocation structureBrian Coca2015-12-231-7/+12
| | | | also added maxdiff setting to see issues clearly when they happen
* Fix unittests for return of invocation from fail_json and exit_jsonToshio Kuratomi2015-12-191-7/+10
|
* Workaround seeming bug in python-2.6's sys.exit()Toshio Kuratomi2015-10-211-3/+15
|
* Update the use of no_log values to cover everything that ↵Toshio Kuratomi2015-10-211-0/+140
heuristic_log_sanitize does. Fixes #12792