Skip to content

Commit

Permalink
Check if param flag values are defined, not truthiness (#366)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 18, 2024
1 parent e1541cf commit b395b94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/modules/rulebook_activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/targets/activation/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}"
Expand Down

0 comments on commit b395b94

Please sign in to comment.