Add sanity tests which ensures that _info and _facts modules set supports_check_mode=True. (#75324)

pull/75413/head
Felix Fontein 3 years ago committed by GitHub
parent 5a38076568
commit b8ebf32d85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- "ansible-test validate-modules - enforce that ``_info`` and ``_facts`` modules set ``supports_check_mode=True`` (https://github.com/ansible/ansible/pull/75324)."

@ -1173,8 +1173,8 @@ class ModuleValidator(Validator):
)
return
self._validate_docs_schema(kwargs, ansible_module_kwargs_schema(for_collection=bool(self.collection)),
'AnsibleModule', 'invalid-ansiblemodule-schema')
schema = ansible_module_kwargs_schema(self.object_name.split('.')[0], for_collection=bool(self.collection))
self._validate_docs_schema(kwargs, schema, 'AnsibleModule', 'invalid-ansiblemodule-schema')
self._validate_argument_spec(docs, spec, kwargs)

@ -253,7 +253,7 @@ def argument_spec_schema(for_collection):
return Schema(schemas)
def ansible_module_kwargs_schema(for_collection):
def ansible_module_kwargs_schema(module_name, for_collection):
schema = {
'argument_spec': argument_spec_schema(for_collection),
'bypass_checks': bool,
@ -262,6 +262,9 @@ def ansible_module_kwargs_schema(for_collection):
'add_file_common_args': bool,
'supports_check_mode': bool,
}
if module_name.endswith(('_info', '_facts')):
del schema['supports_check_mode']
schema[Required('supports_check_mode')] = True
schema.update(argument_spec_modifiers)
return Schema(schema)

Loading…
Cancel
Save