mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-29 05:41:25 -07:00
Allow subspec defaults to be processed when the parent argument is not supplied (#38967)
* Allow subspec defaults to be processed when the parent argument is not supplied * Allow this to be configurable via apply_defaults on the parent * Document attributes of arguments in argument_spec * Switch manageiq_connection to use apply_defaults * add choices to api_version in argument_spec
This commit is contained in:
parent
108eac9339
commit
1663b64e18
6 changed files with 130 additions and 10 deletions
|
@ -412,6 +412,19 @@ class TestComplexOptions:
|
|||
assert isinstance(am.params['foobar']['baz'], str)
|
||||
assert am.params['foobar']['baz'] == 'test data'
|
||||
|
||||
@pytest.mark.parametrize('stdin,spec,expected', [
|
||||
({},
|
||||
{'one': {'type': 'dict', 'apply_defaults': True, 'options': {'two': {'default': True, 'type': 'bool'}}}},
|
||||
{'two': True}),
|
||||
({},
|
||||
{'one': {'type': 'dict', 'options': {'two': {'default': True, 'type': 'bool'}}}},
|
||||
None),
|
||||
], indirect=['stdin'])
|
||||
def test_subspec_not_required_defaults(self, stdin, spec, expected):
|
||||
# Check that top level not required, processed subspec defaults
|
||||
am = basic.AnsibleModule(spec)
|
||||
assert am.params['one'] == expected
|
||||
|
||||
|
||||
class TestLoadFileCommonArguments:
|
||||
@pytest.mark.parametrize('stdin', [{}], indirect=['stdin'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue