From 434f8c0e0cfda73e2e71a09afd388b011073776e Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 6 Jun 2025 20:58:15 +0100 Subject: [PATCH] add monitor validate function upd tests to match console colour changes --- obsws_cli/validate.py | 6 ++++++ tests/test_filter.py | 2 +- tests/test_group.py | 12 ++++++------ tests/test_scene.py | 7 +++++++ tests/test_sceneitem.py | 2 +- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/obsws_cli/validate.py b/obsws_cli/validate.py index cccb413..5a18774 100644 --- a/obsws_cli/validate.py +++ b/obsws_cli/validate.py @@ -46,3 +46,9 @@ def profile_exists(ctx: typer.Context, profile_name: str) -> bool: """Check if a profile exists.""" resp = ctx.obj.get_profile_list() return any(profile == profile_name for profile in resp.profiles) + + +def monitor_exists(ctx: typer.Context, monitor_index: int) -> bool: + """Check if a monitor exists.""" + resp = ctx.obj.get_monitor_list() + return any(monitor['monitorIndex'] == monitor_index for monitor in resp.monitors) diff --git a/tests/test_filter.py b/tests/test_filter.py index 1ffc185..04d084e 100644 --- a/tests/test_filter.py +++ b/tests/test_filter.py @@ -27,4 +27,4 @@ def test_filter_list_invalid_source(): """Test the filter list command with an invalid source.""" result = runner.invoke(app, ['filter', 'list', 'invalid_source']) assert result.exit_code != 0 - assert "No source was found by the name of 'invalid_source'" in result.stderr + assert 'No source was found by the name of invalid_source' in result.stderr diff --git a/tests/test_group.py b/tests/test_group.py index 3650181..3a025b2 100644 --- a/tests/test_group.py +++ b/tests/test_group.py @@ -18,29 +18,29 @@ def test_group_show(): """Test the group show command.""" result = runner.invoke(app, ['group', 'show', 'Scene', 'test_group']) assert result.exit_code == 0 - assert "Group 'test_group' is now visible." in result.stdout + assert 'Group test_group is now visible.' in result.stdout def test_group_toggle(): """Test the group toggle command.""" result = runner.invoke(app, ['group', 'status', 'Scene', 'test_group']) assert result.exit_code == 0 - enabled = "Group 'test_group' is now visible." in result.stdout + enabled = 'Group test_group is now visible.' in result.stdout result = runner.invoke(app, ['group', 'toggle', 'Scene', 'test_group']) assert result.exit_code == 0 if enabled: - assert "Group 'test_group' is now hidden." in result.stdout + assert 'Group test_group is now hidden.' in result.stdout else: - assert "Group 'test_group' is now visible." in result.stdout + assert 'Group test_group is now visible.' in result.stdout def test_group_status(): """Test the group status command.""" result = runner.invoke(app, ['group', 'show', 'Scene', 'test_group']) assert result.exit_code == 0 - assert "Group 'test_group' is now visible." in result.stdout + assert 'Group test_group is now visible.' in result.stdout result = runner.invoke(app, ['group', 'status', 'Scene', 'test_group']) assert result.exit_code == 0 - assert "Group 'test_group' is now visible." in result.stdout + assert 'Group test_group is now visible.' in result.stdout diff --git a/tests/test_scene.py b/tests/test_scene.py index dcbf41a..50bb405 100644 --- a/tests/test_scene.py +++ b/tests/test_scene.py @@ -36,3 +36,10 @@ def test_scene_switch(): result = runner.invoke(app, ['scene', 'switch', 'pytest_scene']) assert result.exit_code == 0 assert 'Switched to program scene: pytest_scene' in result.stdout + + +def test_scene_switch_invalid(): + """Test the scene switch command with an invalid scene.""" + result = runner.invoke(app, ['scene', 'switch', 'non_existent_scene']) + assert result.exit_code != 0 + assert 'Scene non_existent_scene not found' in result.stderr diff --git a/tests/test_sceneitem.py b/tests/test_sceneitem.py index be1a454..958c37e 100644 --- a/tests/test_sceneitem.py +++ b/tests/test_sceneitem.py @@ -29,6 +29,6 @@ def test_sceneitem_transform(): ) assert result.exit_code == 0 assert ( - "Item 'pytest_input_2' in scene 'pytest_scene' has been transformed" + 'Item pytest_input_2 in scene pytest_scene has been transformed' in result.stdout )