mirror of
https://github.com/ansible/awx.git
synced 2024-10-30 13:55:31 +03:00
Handle not-provided falsy values in tower_inventory_source
This commit is contained in:
parent
b444d10369
commit
750c22a150
@ -77,7 +77,6 @@ options:
|
||||
description:
|
||||
- Delete child groups and hosts not found in source.
|
||||
type: bool
|
||||
default: 'no'
|
||||
overwrite_vars:
|
||||
description:
|
||||
- Override vars in child groups and hosts with those from external source.
|
||||
@ -86,7 +85,6 @@ options:
|
||||
description:
|
||||
- Local absolute file path containing a custom Python virtualenv to use.
|
||||
type: str
|
||||
default: ''
|
||||
timeout:
|
||||
description: The amount of time (in seconds) to run before the task is canceled.
|
||||
type: int
|
||||
@ -98,7 +96,6 @@ options:
|
||||
description:
|
||||
- Refresh inventory data from its source each time a job is run.
|
||||
type: bool
|
||||
default: 'no'
|
||||
update_cache_timeout:
|
||||
description:
|
||||
- Time in seconds to consider an inventory sync to be current.
|
||||
@ -173,7 +170,7 @@ def main():
|
||||
group_by=dict(),
|
||||
overwrite=dict(type='bool'),
|
||||
overwrite_vars=dict(type='bool'),
|
||||
custom_virtualenv=dict(default=''),
|
||||
custom_virtualenv=dict(),
|
||||
timeout=dict(type='int'),
|
||||
verbosity=dict(type='int', choices=[0, 1, 2]),
|
||||
update_on_launch=dict(type='bool'),
|
||||
@ -257,7 +254,7 @@ def main():
|
||||
# Layer in all remaining optional information
|
||||
for field_name in OPTIONAL_VARS:
|
||||
field_val = module.params.get(field_name)
|
||||
if field_val:
|
||||
if field_val is not None:
|
||||
inventory_source_fields[field_name] = field_val
|
||||
|
||||
# Attempt to JSON encode source vars
|
||||
|
@ -151,6 +151,31 @@ def test_custom_venv_no_op(run_module, admin_user, base_inventory, mocker, proje
|
||||
assert inv_src.description == 'this is the changed description'
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_falsy_value(run_module, admin_user, base_inventory):
|
||||
result = run_module('tower_inventory_source', dict(
|
||||
name='falsy-test',
|
||||
inventory=base_inventory.name,
|
||||
source='ec2',
|
||||
update_on_launch=True
|
||||
), admin_user)
|
||||
assert not result.get('failed', False), result.get('msg', result)
|
||||
assert result.get('changed', None), result
|
||||
|
||||
inv_src = InventorySource.objects.get(name='falsy-test')
|
||||
assert inv_src.update_on_launch is True
|
||||
|
||||
result = run_module('tower_inventory_source', dict(
|
||||
name='falsy-test',
|
||||
inventory=base_inventory.name,
|
||||
# source='ec2',
|
||||
update_on_launch=False
|
||||
), admin_user)
|
||||
|
||||
inv_src.refresh_from_db()
|
||||
assert inv_src.update_on_launch is False
|
||||
|
||||
|
||||
# Tests related to source-specific parameters
|
||||
#
|
||||
# We want to let the API return issues with "this doesn't support that", etc.
|
||||
|
Loading…
Reference in New Issue
Block a user