mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2025-08-03 10:31:46 +00:00
Compare commits
3 Commits
f852a733c3
...
f335d8ffd2
Author | SHA1 | Date | |
---|---|---|---|
f335d8ffd2 | |||
286cda8066 | |||
e851219ced |
@ -103,17 +103,6 @@ def main(
|
||||
show_default=5,
|
||||
),
|
||||
] = settings.get('timeout'),
|
||||
version: Annotated[
|
||||
bool,
|
||||
typer.Option(
|
||||
'--version',
|
||||
'-v',
|
||||
is_eager=True,
|
||||
help='Show the CLI version and exit',
|
||||
show_default=False,
|
||||
callback=version_callback,
|
||||
),
|
||||
] = False,
|
||||
style: Annotated[
|
||||
str,
|
||||
typer.Option(
|
||||
@ -135,6 +124,17 @@ def main(
|
||||
show_default=False,
|
||||
),
|
||||
] = settings.get('style_no_border'),
|
||||
version: Annotated[
|
||||
bool,
|
||||
typer.Option(
|
||||
'--version',
|
||||
'-v',
|
||||
is_eager=True,
|
||||
help='Show the CLI version and exit',
|
||||
show_default=False,
|
||||
callback=version_callback,
|
||||
),
|
||||
] = False,
|
||||
debug: Annotated[
|
||||
bool,
|
||||
typer.Option(
|
||||
@ -151,7 +151,9 @@ def main(
|
||||
):
|
||||
"""obsws_cli is a command line interface for the OBS WebSocket API."""
|
||||
ctx.ensure_object(dict)
|
||||
ctx.obj['obsws'] = ctx.with_resource(obsws.ReqClient(**ctx.params))
|
||||
ctx.obj['obsws'] = ctx.with_resource(
|
||||
obsws.ReqClient(host=host, port=port, password=password, timeout=timeout)
|
||||
)
|
||||
ctx.obj['style'] = styles.request_style_obj(style, no_border)
|
||||
|
||||
|
||||
|
@ -24,6 +24,10 @@ def list_(
|
||||
"""List all hotkeys."""
|
||||
resp = ctx.obj['obsws'].get_hotkey_list()
|
||||
|
||||
if not resp.hotkeys:
|
||||
console.out.print('No hotkeys found.')
|
||||
raise typer.Exit()
|
||||
|
||||
table = Table(
|
||||
title='Hotkeys',
|
||||
padding=(0, 2),
|
||||
|
@ -22,6 +22,10 @@ def list_(ctx: typer.Context):
|
||||
"""List profiles."""
|
||||
resp = ctx.obj['obsws'].get_profile_list()
|
||||
|
||||
if not resp.profiles:
|
||||
console.out.print('No profiles found.')
|
||||
raise typer.Exit()
|
||||
|
||||
table = Table(
|
||||
title='Profiles', padding=(0, 2), border_style=ctx.obj['style'].border
|
||||
)
|
||||
|
@ -21,16 +21,15 @@ def main():
|
||||
def list_monitors(ctx: typer.Context):
|
||||
"""List available monitors."""
|
||||
resp = ctx.obj['obsws'].get_monitor_list()
|
||||
|
||||
if not resp.monitors:
|
||||
console.out.print('No monitors found.')
|
||||
return
|
||||
|
||||
monitors = sorted(
|
||||
((m['monitorIndex'], m['monitorName']) for m in resp.monitors),
|
||||
key=lambda m: m[0],
|
||||
)
|
||||
|
||||
if not monitors:
|
||||
console.out.print('No monitors found.')
|
||||
raise typer.Exit()
|
||||
|
||||
table = Table(
|
||||
title='Available Monitors',
|
||||
padding=(0, 2),
|
||||
|
@ -29,6 +29,10 @@ def list_(
|
||||
for scene in reversed(resp.scenes)
|
||||
)
|
||||
|
||||
if not scenes:
|
||||
console.out.print('No scenes found.')
|
||||
raise typer.Exit()
|
||||
|
||||
active_scene = ctx.obj['obsws'].get_current_program_scene().scene_name
|
||||
|
||||
table = Table(title='Scenes', padding=(0, 2), border_style=ctx.obj['style'].border)
|
||||
|
@ -21,6 +21,10 @@ def list_(ctx: typer.Context):
|
||||
"""List all scene collections."""
|
||||
resp = ctx.obj['obsws'].get_scene_collection_list()
|
||||
|
||||
if not resp.scene_collections:
|
||||
console.out.print('No scene collections found.')
|
||||
raise typer.Exit()
|
||||
|
||||
table = Table(
|
||||
title='Scene Collections',
|
||||
padding=(0, 2),
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""pytest configuration file."""
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
import obsws_python as obsws
|
||||
from dotenv import find_dotenv, load_dotenv
|
||||
@ -44,9 +45,54 @@ def pytest_sessionstart(session):
|
||||
},
|
||||
)
|
||||
|
||||
session.obsws.set_current_scene_collection('test-collection')
|
||||
|
||||
session.obsws.create_profile('pytest_profile')
|
||||
time.sleep(0.1) # Wait for the profile to be created
|
||||
session.obsws.set_profile_parameter(
|
||||
'SimpleOutput',
|
||||
'RecRB',
|
||||
'true',
|
||||
)
|
||||
# hack to ensure the replay buffer is enabled
|
||||
session.obsws.set_current_profile('Untitled')
|
||||
session.obsws.set_current_profile('pytest_profile')
|
||||
session.obsws.create_scene('pytest_scene')
|
||||
|
||||
# Ensure Desktop Audio is created.
|
||||
desktop_audio_kinds = {
|
||||
'windows': 'wasapi_output_capture',
|
||||
'linux': 'pulse_output_capture',
|
||||
'darwin': 'coreaudio_output_capture',
|
||||
}
|
||||
platform = os.environ.get('OBS_TESTS_PLATFORM', os.uname().sysname.lower())
|
||||
try:
|
||||
session.obsws.create_input(
|
||||
sceneName='pytest_scene',
|
||||
inputName='Desktop Audio',
|
||||
inputKind=desktop_audio_kinds[platform],
|
||||
inputSettings={'device_id': 'default'},
|
||||
sceneItemEnabled=True,
|
||||
)
|
||||
except obsws.error.OBSSDKRequestError as e:
|
||||
if e.code == 601:
|
||||
"""input already exists, continue."""
|
||||
# Ensure Mic/Aux is created.
|
||||
mic_kinds = {
|
||||
'windows': 'wasapi_input_capture',
|
||||
'linux': 'pulse_input_capture',
|
||||
'darwin': 'coreaudio_input_capture',
|
||||
}
|
||||
try:
|
||||
session.obsws.create_input(
|
||||
sceneName='pytest_scene',
|
||||
inputName='Mic/Aux',
|
||||
inputKind=mic_kinds[platform],
|
||||
inputSettings={'device_id': 'default'},
|
||||
sceneItemEnabled=True,
|
||||
)
|
||||
except obsws.error.OBSSDKRequestError as e:
|
||||
if e.code == 601:
|
||||
"""input already exists, continue."""
|
||||
|
||||
session.obsws.create_input(
|
||||
sceneName='pytest_scene',
|
||||
inputName='pytest_input',
|
||||
@ -131,7 +177,7 @@ def pytest_sessionfinish(session, exitstatus):
|
||||
|
||||
session.obsws.remove_scene('pytest_scene')
|
||||
|
||||
session.obsws.set_current_scene_collection('default')
|
||||
session.obsws.set_current_scene_collection('Untitled')
|
||||
|
||||
resp = session.obsws.get_stream_status()
|
||||
if resp.output_active:
|
||||
@ -149,6 +195,8 @@ def pytest_sessionfinish(session, exitstatus):
|
||||
if resp.studio_mode_enabled:
|
||||
session.obsws.set_studio_mode_enabled(False)
|
||||
|
||||
session.obsws.remove_profile('pytest_profile')
|
||||
|
||||
# Close the OBS WebSocket client connection
|
||||
session.obsws.disconnect()
|
||||
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_filter_list():
|
||||
|
@ -1,10 +1,18 @@
|
||||
"""Unit tests for the group command in the OBS WebSocket CLI."""
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
if os.environ.get('OBS_TESTS_SKIP_GROUP_TESTS'):
|
||||
pytest.skip(
|
||||
'Skipping group tests as per environment variable', allow_module_level=True
|
||||
)
|
||||
|
||||
|
||||
def test_group_list():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_hotkey_list():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_input_list():
|
||||
@ -13,10 +13,7 @@ def test_input_list():
|
||||
assert result.exit_code == 0
|
||||
assert 'Desktop Audio' in result.stdout
|
||||
assert 'Mic/Aux' in result.stdout
|
||||
assert all(
|
||||
item in result.stdout
|
||||
for item in ('Colour Source', 'Colour Source 2', 'Colour Source 3')
|
||||
)
|
||||
assert all(item in result.stdout for item in ('pytest_input', 'pytest_input_2'))
|
||||
|
||||
|
||||
def test_input_list_filter_input():
|
||||
@ -39,9 +36,6 @@ def test_input_list_filter_colour():
|
||||
"""Test the input list command with colour filter."""
|
||||
result = runner.invoke(app, ['input', 'list', '--colour'])
|
||||
assert result.exit_code == 0
|
||||
assert all(
|
||||
item in result.stdout
|
||||
for item in ('Colour Source', 'Colour Source 2', 'Colour Source 3')
|
||||
)
|
||||
assert all(item in result.stdout for item in ('pytest_input', 'pytest_input_2'))
|
||||
assert 'Desktop Audio' not in result.stdout
|
||||
assert 'Mic/Aux' not in result.stdout
|
||||
|
@ -6,7 +6,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_record_start():
|
||||
|
@ -1,10 +1,19 @@
|
||||
"""Unit tests for the replaybuffer command in the OBS WebSocket CLI."""
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
if os.environ.get('OBS_TESTS_SKIP_REPLAYBUFFER_TESTS'):
|
||||
pytest.skip(
|
||||
'Skipping replaybuffer tests as per environment variable',
|
||||
allow_module_level=True,
|
||||
)
|
||||
|
||||
|
||||
def test_replaybuffer_start():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_scene_list():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_sceneitem_list():
|
||||
|
@ -6,7 +6,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_stream_start():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_studio_enable():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_text_update():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_version():
|
||||
|
Loading…
x
Reference in New Issue
Block a user