mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-05 03:37:01 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -15,13 +15,13 @@ from ansible.module_utils.common.text.converters import to_bytes
|
|||
|
||||
@_contextlib.contextmanager
|
||||
def set_module_args(args):
|
||||
if '_ansible_remote_tmp' not in args:
|
||||
args['_ansible_remote_tmp'] = '/tmp'
|
||||
if '_ansible_keep_remote_files' not in args:
|
||||
args['_ansible_keep_remote_files'] = False
|
||||
if "_ansible_remote_tmp" not in args:
|
||||
args["_ansible_remote_tmp"] = "/tmp"
|
||||
if "_ansible_keep_remote_files" not in args:
|
||||
args["_ansible_keep_remote_files"] = False
|
||||
|
||||
serialized_args = to_bytes(json.dumps({'ANSIBLE_MODULE_ARGS': args}))
|
||||
with patch.object(basic, '_ANSIBLE_ARGS', serialized_args):
|
||||
serialized_args = to_bytes(json.dumps({"ANSIBLE_MODULE_ARGS": args}))
|
||||
with patch.object(basic, "_ANSIBLE_ARGS", serialized_args):
|
||||
yield
|
||||
|
||||
|
||||
|
|
@ -34,22 +34,21 @@ class AnsibleFailJson(Exception):
|
|||
|
||||
|
||||
def exit_json(*args, **kwargs):
|
||||
if 'changed' not in kwargs:
|
||||
kwargs['changed'] = False
|
||||
if "changed" not in kwargs:
|
||||
kwargs["changed"] = False
|
||||
raise AnsibleExitJson(kwargs)
|
||||
|
||||
|
||||
def fail_json(*args, **kwargs):
|
||||
kwargs['failed'] = True
|
||||
kwargs["failed"] = True
|
||||
raise AnsibleFailJson(kwargs)
|
||||
|
||||
|
||||
class ModuleTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.mock_module = patch.multiple(basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json)
|
||||
self.mock_module.start()
|
||||
self.mock_sleep = patch('time.sleep')
|
||||
self.mock_sleep = patch("time.sleep")
|
||||
self.mock_sleep.start()
|
||||
set_module_args({})
|
||||
self.addCleanup(self.mock_module.stop)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue