From b395b94cb4730dd40a681d49116fcdcc93d23e58 Mon Sep 17 00:00:00 2001 From: Zach LeBlanc Date: Wed, 18 Dec 2024 13:02:50 -0600 Subject: [PATCH] Check if param flag values are defined, not truthiness (#366) * Check if param flag values are defined, not truthiness * add check in integration tests to verify disabled state * add test for swap_single_source flag * chore: auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * merge --------- Co-authored-by: Alex Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- plugins/modules/rulebook_activation.py | 4 ++-- tests/integration/targets/activation/tasks/main.yml | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/modules/rulebook_activation.py b/plugins/modules/rulebook_activation.py index 9212ac8e..d5170ade 100644 --- a/plugins/modules/rulebook_activation.py +++ b/plugins/modules/rulebook_activation.py @@ -412,13 +412,13 @@ def create_params( if module.params.get("restart_policy"): activation_params["restart_policy"] = module.params["restart_policy"] - if module.params.get("enabled"): + if module.params.get("enabled") is not None: activation_params["is_enabled"] = module.params["enabled"] if not is_aap_24 and module.params.get("log_level"): activation_params["log_level"] = module.params["log_level"] - if not is_aap_24 and module.params.get("swap_single_source"): + if not is_aap_24 and module.params.get("swap_single_source") is not None: activation_params["swap_single_source"] = module.params["swap_single_source"] return activation_params diff --git a/tests/integration/targets/activation/tasks/main.yml b/tests/integration/targets/activation/tasks/main.yml index 6c94e461..28ef6755 100644 --- a/tests/integration/targets/activation/tasks/main.yml +++ b/tests/integration/targets/activation/tasks/main.yml @@ -269,6 +269,12 @@ - name: Get information about the rulebook activation ansible.eda.rulebook_activation_info: name: "{{ activation_name }}" + register: _result_activation_info + + - name: Assert that rulebook activation is disabled + ansible.builtin.assert: + that: + - not _result_activation_info.activations[0].is_enabled - name: List all the rulebook activations ansible.eda.rulebook_activation_info: @@ -380,6 +386,7 @@ enabled: False awx_token_name: "{{ awx_token_name }}" organization_name: Default + swap_single_source: False event_streams: - event_stream: "{{ event_stream_name }}" source_name: "{{ _result_rulebook_info.rulebooks[0].sources[0].name }}"