validate-modules: Check for correct values in choice (#82266)

* validate-modules: Check for correct values in choice

* validate-modules test now checks the length of choices and
  correct option values inside the choice.

Fixes: #82179

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>

* Fix sanity tests

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>

---------

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/82316/head
Abhijeet Kasurde 6 months ago committed by GitHub
parent 0806da55b1
commit e6e19e37f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,33 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
DOCUMENTATION = """
module: invalid_choice_value
short_description: Test for equal length of chocies with correct options
description: Test for equal length of chocies with correct options
author:
- Ansible Core Team
options:
caching:
description:
- Type of Caching.
type: str
choices:
- ReadOnly
- ReadWrite
"""
EXAMPLES = """#"""
RETURN = """"""
from ansible.module_utils.basic import AnsibleModule
if __name__ == "__main__":
module = AnsibleModule(
argument_spec=dict(caching=dict(type="str", choices=["ReadOnly", "ReadOnly"])),
supports_check_mode=False,
)
module.exit_json()

@ -4,6 +4,7 @@ plugins/modules/check_mode_attribute_2.py:0:0: attributes-check-mode: The module
plugins/modules/check_mode_attribute_3.py:0:0: attributes-check-mode: The module does declare support for check mode, but the check_mode attribute's support value is 'none'
plugins/modules/check_mode_attribute_4.py:0:0: attributes-check-mode-details: The module declares it does not fully support check mode, but has no details on what exactly that means
plugins/modules/import_order.py:7:0: import-before-documentation: Import found before documentation variables. All imports must appear below DOCUMENTATION/EXAMPLES/RETURN.
plugins/modules/invalid_choice_value.py:0:0: doc-choices-do-not-match-spec: Argument 'caching' in argument_spec defines choices as (['ReadOnly', 'ReadOnly']) but documentation defines choices as (['ReadOnly', 'ReadWrite'])
plugins/modules/invalid_yaml_syntax.py:0:0: deprecation-mismatch: "meta/runtime.yml" and DOCUMENTATION.deprecation do not agree.
plugins/modules/invalid_yaml_syntax.py:0:0: missing-documentation: No DOCUMENTATION provided
plugins/modules/invalid_yaml_syntax.py:7:15: documentation-syntax-error: DOCUMENTATION is not valid YAML

@ -192,7 +192,7 @@ def compare_unordered_lists(a, b):
- unordered lists
- unhashable elements
"""
return len(a) == len(b) and all(x in b for x in a)
return len(a) == len(b) and all(x in b for x in a) and all(x in a for x in b)
class NoArgsAnsibleModule(AnsibleModule):

Loading…
Cancel
Save