add monitor validate function

upd tests to match console colour changes
This commit is contained in:
onyx-and-iris 2025-06-06 20:58:15 +01:00
parent 81518a14ea
commit 434f8c0e0c
5 changed files with 21 additions and 8 deletions

View File

@ -46,3 +46,9 @@ def profile_exists(ctx: typer.Context, profile_name: str) -> bool:
"""Check if a profile exists.""" """Check if a profile exists."""
resp = ctx.obj.get_profile_list() resp = ctx.obj.get_profile_list()
return any(profile == profile_name for profile in resp.profiles) 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)

View File

@ -27,4 +27,4 @@ def test_filter_list_invalid_source():
"""Test the filter list command with an invalid source.""" """Test the filter list command with an invalid source."""
result = runner.invoke(app, ['filter', 'list', 'invalid_source']) result = runner.invoke(app, ['filter', 'list', 'invalid_source'])
assert result.exit_code != 0 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

View File

@ -18,29 +18,29 @@ def test_group_show():
"""Test the group show command.""" """Test the group show command."""
result = runner.invoke(app, ['group', 'show', 'Scene', 'test_group']) result = runner.invoke(app, ['group', 'show', 'Scene', 'test_group'])
assert result.exit_code == 0 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(): def test_group_toggle():
"""Test the group toggle command.""" """Test the group toggle command."""
result = runner.invoke(app, ['group', 'status', 'Scene', 'test_group']) result = runner.invoke(app, ['group', 'status', 'Scene', 'test_group'])
assert result.exit_code == 0 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']) result = runner.invoke(app, ['group', 'toggle', 'Scene', 'test_group'])
assert result.exit_code == 0 assert result.exit_code == 0
if enabled: if enabled:
assert "Group 'test_group' is now hidden." in result.stdout assert 'Group test_group is now hidden.' in result.stdout
else: 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(): def test_group_status():
"""Test the group status command.""" """Test the group status command."""
result = runner.invoke(app, ['group', 'show', 'Scene', 'test_group']) result = runner.invoke(app, ['group', 'show', 'Scene', 'test_group'])
assert result.exit_code == 0 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']) result = runner.invoke(app, ['group', 'status', 'Scene', 'test_group'])
assert result.exit_code == 0 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

View File

@ -36,3 +36,10 @@ def test_scene_switch():
result = runner.invoke(app, ['scene', 'switch', 'pytest_scene']) result = runner.invoke(app, ['scene', 'switch', 'pytest_scene'])
assert result.exit_code == 0 assert result.exit_code == 0
assert 'Switched to program scene: pytest_scene' in result.stdout 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

View File

@ -29,6 +29,6 @@ def test_sceneitem_transform():
) )
assert result.exit_code == 0 assert result.exit_code == 0
assert ( 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 in result.stdout
) )