Added test for 'RETURN' field in validate-modules (#23322)

* Added test for 'RETURN' field in validate-modules

* print the field being tested.

Useful when the RETURN structure is complex.

* Fixed schema after CI traceback fail

* Fixed list_string_types

* Fixed line in 319 code for RETURN
This commit is contained in:
Andrea Tartaglia 2017-05-02 09:01:53 +01:00 committed by John R Barker
commit 4e4fc9cb4c
3 changed files with 34 additions and 3 deletions

View file

@ -41,7 +41,7 @@ from ansible.utils.plugin_docs import BLACKLIST, get_docstring
from module_args import get_argument_spec
from schema import doc_schema, option_schema, metadata_schema
from schema import doc_schema, option_schema, metadata_schema, return_schema
from utils import CaptureStd, parse_yaml
from voluptuous.humanize import humanize_error
@ -696,9 +696,13 @@ class ModuleValidator(Validator):
else:
self.warnings.append((312, 'No RETURN provided'))
else:
_, errors, traces = parse_yaml(doc_info['RETURN']['value'],
data, errors, traces = parse_yaml(doc_info['RETURN']['value'],
doc_info['RETURN']['lineno'],
self.name, 'RETURN')
if data:
for ret_key in data:
self._validate_docs_schema(data[ret_key], return_schema(data[ret_key]), 'RETURN.%s' % ret_key, 319)
self.errors.extend([(313, error) for error in errors])
self.traces.extend(traces)