From 0b6e8f8d445ab52bc31fd40b6572414cc0a8936e Mon Sep 17 00:00:00 2001 From: Ricardo Boni Date: Wed, 5 Nov 2025 18:08:35 -0500 Subject: [PATCH] fix: Heartbeat demo should not print the interrupt message when stopped --- dk-installer.py | 6 ++++-- tests/test_obs_demo.py | 13 ++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dk-installer.py b/dk-installer.py index 113711f..ab00f94 100755 --- a/dk-installer.py +++ b/dk-installer.py @@ -1643,8 +1643,10 @@ class ObsRunHeartbeatDemoAction(DemoContainerAction): def execute(self, args): CONSOLE.title("Run Observability Heartbeat demo") - self.run_dk_demo_container("obs-heartbeat-demo") - CONSOLE.msg("Observability Heartbeat demo stopped") + try: + self.run_dk_demo_container("obs-heartbeat-demo") + except KeyboardInterrupt: + CONSOLE.msg("Observability Heartbeat demo stopped") class UpdateComposeFileStep(Step): diff --git a/tests/test_obs_demo.py b/tests/test_obs_demo.py index 0f77ac1..15c341f 100644 --- a/tests/test_obs_demo.py +++ b/tests/test_obs_demo.py @@ -1,4 +1,4 @@ -from unittest.mock import call +from unittest.mock import call, patch import pytest @@ -44,3 +44,14 @@ def test_obs_demo_action(action_class, arg_action, demo_cmd, args_mock, start_cm ], any_order=True, ) + + +@pytest.mark.unit +def test_obs_heartbeat_demo_stop(args_mock, start_cmd_mock, demo_config_path): + action = ObsRunHeartbeatDemoAction() + with patch.object(action, "run_dk_demo_container") as run_demo_cmd_mock: + run_demo_cmd_mock.side_effect = KeyboardInterrupt + + action.execute(args_mock) + + run_demo_cmd_mock.assert_called_with("obs-heartbeat-demo")