mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2025-06-07 20:20:32 +01:00
replaybuffer start/stop now check status first
add replaybuffer tests
This commit is contained in:
parent
0a944f1f58
commit
df6f65eda0
@ -18,6 +18,11 @@ def main():
|
|||||||
@app.command('start | s')
|
@app.command('start | s')
|
||||||
def start(ctx: typer.Context):
|
def start(ctx: typer.Context):
|
||||||
"""Start the replay buffer."""
|
"""Start the replay buffer."""
|
||||||
|
resp = ctx.obj.get_replay_buffer_status()
|
||||||
|
if resp.output_active:
|
||||||
|
err_console.print('Replay buffer is already active.')
|
||||||
|
raise typer.Exit(1)
|
||||||
|
|
||||||
ctx.obj.start_replay_buffer()
|
ctx.obj.start_replay_buffer()
|
||||||
out_console.print('Replay buffer started.')
|
out_console.print('Replay buffer started.')
|
||||||
|
|
||||||
@ -25,6 +30,11 @@ def start(ctx: typer.Context):
|
|||||||
@app.command('stop | st')
|
@app.command('stop | st')
|
||||||
def stop(ctx: typer.Context):
|
def stop(ctx: typer.Context):
|
||||||
"""Stop the replay buffer."""
|
"""Stop the replay buffer."""
|
||||||
|
resp = ctx.obj.get_replay_buffer_status()
|
||||||
|
if not resp.output_active:
|
||||||
|
err_console.print('Replay buffer is not active.')
|
||||||
|
raise typer.Exit(1)
|
||||||
|
|
||||||
ctx.obj.stop_replay_buffer()
|
ctx.obj.stop_replay_buffer()
|
||||||
out_console.print('Replay buffer stopped.')
|
out_console.print('Replay buffer stopped.')
|
||||||
|
|
||||||
|
52
tests/test_replaybuffer.py
Normal file
52
tests/test_replaybuffer.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
"""Unit tests for the replaybuffer command in the OBS WebSocket CLI."""
|
||||||
|
|
||||||
|
from typer.testing import CliRunner
|
||||||
|
|
||||||
|
from obsws_cli.app import app
|
||||||
|
|
||||||
|
runner = CliRunner(mix_stderr=False)
|
||||||
|
|
||||||
|
|
||||||
|
def test_replaybuffer_start():
|
||||||
|
"""Test the replay buffer start command."""
|
||||||
|
resp = runner.invoke(app, ['replaybuffer', 'status'])
|
||||||
|
assert resp.exit_code == 0
|
||||||
|
active = 'Replay buffer is active.' in resp.stdout
|
||||||
|
|
||||||
|
resp = runner.invoke(app, ['replaybuffer', 'start'])
|
||||||
|
if active:
|
||||||
|
assert resp.exit_code != 0
|
||||||
|
assert 'Replay buffer is already active.' in resp.stderr
|
||||||
|
else:
|
||||||
|
assert resp.exit_code == 0
|
||||||
|
assert 'Replay buffer started.' in resp.stdout
|
||||||
|
|
||||||
|
|
||||||
|
def test_replaybuffer_stop():
|
||||||
|
"""Test the replay buffer stop command."""
|
||||||
|
resp = runner.invoke(app, ['replaybuffer', 'status'])
|
||||||
|
assert resp.exit_code == 0
|
||||||
|
active = 'Replay buffer is active.' in resp.stdout
|
||||||
|
|
||||||
|
resp = runner.invoke(app, ['replaybuffer', 'stop'])
|
||||||
|
if not active:
|
||||||
|
assert resp.exit_code != 0
|
||||||
|
assert 'Replay buffer is not active.' in resp.stderr
|
||||||
|
else:
|
||||||
|
assert resp.exit_code == 0
|
||||||
|
assert 'Replay buffer stopped.' in resp.stdout
|
||||||
|
|
||||||
|
|
||||||
|
def test_replaybuffer_toggle():
|
||||||
|
"""Test the replay buffer toggle command."""
|
||||||
|
resp = runner.invoke(app, ['replaybuffer', 'status'])
|
||||||
|
assert resp.exit_code == 0
|
||||||
|
active = 'Replay buffer is active.' in resp.stdout
|
||||||
|
|
||||||
|
resp = runner.invoke(app, ['replaybuffer', 'toggle'])
|
||||||
|
if active:
|
||||||
|
assert resp.exit_code == 0
|
||||||
|
assert 'Replay buffer is not active.' in resp.stdout
|
||||||
|
else:
|
||||||
|
assert resp.exit_code == 0
|
||||||
|
assert 'Replay buffer is active.' in resp.stdout
|
Loading…
x
Reference in New Issue
Block a user