mirror of
https://github.com/ansible/awx.git
synced 2026-02-05 03:24:50 -03:30
Merge pull request #7770 from AlanCoding/falsy_inv
Handle not-provided falsy values in tower_inventory_source Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -77,7 +77,6 @@ options:
|
|||||||
description:
|
description:
|
||||||
- Delete child groups and hosts not found in source.
|
- Delete child groups and hosts not found in source.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
|
||||||
overwrite_vars:
|
overwrite_vars:
|
||||||
description:
|
description:
|
||||||
- Override vars in child groups and hosts with those from external source.
|
- Override vars in child groups and hosts with those from external source.
|
||||||
@@ -86,7 +85,6 @@ options:
|
|||||||
description:
|
description:
|
||||||
- Local absolute file path containing a custom Python virtualenv to use.
|
- Local absolute file path containing a custom Python virtualenv to use.
|
||||||
type: str
|
type: str
|
||||||
default: ''
|
|
||||||
timeout:
|
timeout:
|
||||||
description: The amount of time (in seconds) to run before the task is canceled.
|
description: The amount of time (in seconds) to run before the task is canceled.
|
||||||
type: int
|
type: int
|
||||||
@@ -98,7 +96,6 @@ options:
|
|||||||
description:
|
description:
|
||||||
- Refresh inventory data from its source each time a job is run.
|
- Refresh inventory data from its source each time a job is run.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
|
||||||
update_cache_timeout:
|
update_cache_timeout:
|
||||||
description:
|
description:
|
||||||
- Time in seconds to consider an inventory sync to be current.
|
- Time in seconds to consider an inventory sync to be current.
|
||||||
@@ -173,7 +170,7 @@ def main():
|
|||||||
group_by=dict(),
|
group_by=dict(),
|
||||||
overwrite=dict(type='bool'),
|
overwrite=dict(type='bool'),
|
||||||
overwrite_vars=dict(type='bool'),
|
overwrite_vars=dict(type='bool'),
|
||||||
custom_virtualenv=dict(default=''),
|
custom_virtualenv=dict(),
|
||||||
timeout=dict(type='int'),
|
timeout=dict(type='int'),
|
||||||
verbosity=dict(type='int', choices=[0, 1, 2]),
|
verbosity=dict(type='int', choices=[0, 1, 2]),
|
||||||
update_on_launch=dict(type='bool'),
|
update_on_launch=dict(type='bool'),
|
||||||
@@ -257,7 +254,7 @@ def main():
|
|||||||
# Layer in all remaining optional information
|
# Layer in all remaining optional information
|
||||||
for field_name in OPTIONAL_VARS:
|
for field_name in OPTIONAL_VARS:
|
||||||
field_val = module.params.get(field_name)
|
field_val = module.params.get(field_name)
|
||||||
if field_val:
|
if field_val is not None:
|
||||||
inventory_source_fields[field_name] = field_val
|
inventory_source_fields[field_name] = field_val
|
||||||
|
|
||||||
# Attempt to JSON encode source vars
|
# 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'
|
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
|
# Tests related to source-specific parameters
|
||||||
#
|
#
|
||||||
# We want to let the API return issues with "this doesn't support that", etc.
|
# We want to let the API return issues with "this doesn't support that", etc.
|
||||||
|
|||||||
Reference in New Issue
Block a user