diff --git a/tests/unit/action/test_run_job_template.py b/tests/unit/action/test_run_job_template.py index 19da3492..99c0c1d4 100644 --- a/tests/unit/action/test_run_job_template.py +++ b/tests/unit/action/test_run_job_template.py @@ -16,6 +16,7 @@ import pytest +from ansible_rulebook import terminal from ansible_rulebook.action.control import Control from ansible_rulebook.action.metadata import Metadata from ansible_rulebook.action.run_job_template import RunJobTemplate @@ -119,7 +120,7 @@ async def test_run_job_template_exception(err_msg, err): @pytest.mark.parametrize("drools_call,additional_args", DROOLS_CALLS) @pytest.mark.asyncio -async def test_run_job_template(drools_call, additional_args): +async def test_run_job_template(drools_call, additional_args, capsys): queue = asyncio.Queue() metadata = Metadata( rule="r1", @@ -156,10 +157,17 @@ async def test_run_job_template(drools_call, additional_args): return_value=controller_job, ): with patch(drools_call) as drools_mock: - await RunJobTemplate(metadata, control, **action_args)() + await RunJobTemplate( + metadata, + control, + print_events=True, + **action_args, + )() + captured = capsys.readouterr() drools_mock.assert_called_once() _validate(queue, True) + assert terminal.Display.get_banners("job: set-facts", captured.out) URL_PARAMETERS = [ diff --git a/tests/unit/action/test_run_playbook.py b/tests/unit/action/test_run_playbook.py index d4d888ec..afdeeb18 100644 --- a/tests/unit/action/test_run_playbook.py +++ b/tests/unit/action/test_run_playbook.py @@ -18,6 +18,7 @@ import pytest from freezegun import freeze_time +from ansible_rulebook import terminal from ansible_rulebook.action.control import Control from ansible_rulebook.action.metadata import Metadata from ansible_rulebook.action.run_playbook import RunPlaybook @@ -94,7 +95,7 @@ def _validate(queue, metadata, status, rc): @pytest.mark.asyncio @freeze_time("2023-06-11 12:13:14") @pytest.mark.asyncio -async def test_run_playbook(drools_call, additional_args): +async def test_run_playbook(drools_call, additional_args, capsys): os.chdir(HERE) queue = asyncio.Queue() metadata = Metadata( @@ -131,12 +132,16 @@ async def test_run_playbook(drools_call, additional_args): with patch("uuid.uuid4", return_value=DUMMY_UUID): with patch(drools_call) as drools_mock: - await RunPlaybook(metadata, control, **action_args)() + await RunPlaybook( + metadata, control, print_events=True, **action_args + )() + captured = capsys.readouterr() drools_mock.assert_called_once_with( action_args["ruleset"], set_fact_args ) _validate(queue, metadata, "successful", 0) + assert terminal.Display.get_banners("playbook: set-facts", captured.out) @freeze_time("2023-06-11 12:13:14") diff --git a/tests/unit/action/test_run_workflow_template.py b/tests/unit/action/test_run_workflow_template.py index fcd14a33..d9023c20 100644 --- a/tests/unit/action/test_run_workflow_template.py +++ b/tests/unit/action/test_run_workflow_template.py @@ -16,6 +16,7 @@ import pytest +from ansible_rulebook import terminal from ansible_rulebook.action.control import Control from ansible_rulebook.action.metadata import Metadata from ansible_rulebook.action.run_workflow_template import RunWorkflowTemplate @@ -122,7 +123,7 @@ async def test_run_workflow_template_exception(err_msg, err): @pytest.mark.parametrize("drools_call,additional_args", DROOLS_CALLS) @pytest.mark.asyncio -async def test_run_workflow_template(drools_call, additional_args): +async def test_run_workflow_template(drools_call, additional_args, capsys): queue = asyncio.Queue() metadata = Metadata( rule="r1", @@ -159,10 +160,19 @@ async def test_run_workflow_template(drools_call, additional_args): return_value=controller_job, ): with patch(drools_call) as drools_mock: - await RunWorkflowTemplate(metadata, control, **action_args)() + await RunWorkflowTemplate( + metadata, + control, + print_events=True, + **action_args, + )() + captured = capsys.readouterr() drools_mock.assert_called_once() _validate(queue, True) + assert terminal.Display.get_banners( + "workflow: set-facts", captured.out + ) @pytest.mark.asyncio