mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2025-06-07 20:20:32 +01:00
upd stream/record tests
test different exit codes and outputs according to current stream/record state
This commit is contained in:
parent
f8d3ed75cb
commit
5bfd642032
@ -9,27 +9,36 @@ from obsws_cli.app import app
|
|||||||
runner = CliRunner(mix_stderr=False)
|
runner = CliRunner(mix_stderr=False)
|
||||||
|
|
||||||
|
|
||||||
def test_record_start_status_stop():
|
def test_record_start():
|
||||||
"""Test the record start command."""
|
"""Test the record start command."""
|
||||||
result = runner.invoke(app, ['record', 'start'])
|
|
||||||
assert result.exit_code == 0
|
|
||||||
assert 'Recording started successfully.' in result.stdout
|
|
||||||
|
|
||||||
time.sleep(0.5) # Wait for the recording to start
|
|
||||||
|
|
||||||
result = runner.invoke(app, ['record', 'status'])
|
result = runner.invoke(app, ['record', 'status'])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert 'Recording is in progress.' in result.stdout
|
active = 'Recording is in progress.' in result.stdout
|
||||||
|
|
||||||
|
result = runner.invoke(app, ['record', 'start'])
|
||||||
|
if active:
|
||||||
|
assert result.exit_code != 0
|
||||||
|
assert 'Recording is already in progress, cannot start.' in result.stderr
|
||||||
|
else:
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert 'Recording started successfully.' in result.stdout
|
||||||
|
time.sleep(0.5) # Wait for the recording to start
|
||||||
|
|
||||||
|
|
||||||
|
def test_record_stop():
|
||||||
|
"""Test the record stop command."""
|
||||||
|
result = runner.invoke(app, ['record', 'status'])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
active = 'Recording is in progress.' in result.stdout
|
||||||
|
|
||||||
result = runner.invoke(app, ['record', 'stop'])
|
result = runner.invoke(app, ['record', 'stop'])
|
||||||
assert result.exit_code == 0
|
if not active:
|
||||||
assert 'Recording stopped successfully. Saved to:' in result.stdout
|
assert result.exit_code != 0
|
||||||
|
assert 'Recording is not in progress, cannot stop.' in result.stderr
|
||||||
time.sleep(0.5) # Wait for the recording to stop
|
else:
|
||||||
|
assert result.exit_code == 0
|
||||||
result = runner.invoke(app, ['record', 'status'])
|
assert 'Recording stopped successfully.' in result.stdout
|
||||||
assert result.exit_code == 0
|
time.sleep(0.5) # Wait for the recording to stop
|
||||||
assert 'Recording is not in progress.' in result.stdout
|
|
||||||
|
|
||||||
|
|
||||||
def test_record_toggle():
|
def test_record_toggle():
|
||||||
|
@ -16,14 +16,14 @@ def test_stream_start():
|
|||||||
active = 'Streaming is in progress' in result.stdout
|
active = 'Streaming is in progress' in result.stdout
|
||||||
|
|
||||||
result = runner.invoke(app, ['stream', 'start'])
|
result = runner.invoke(app, ['stream', 'start'])
|
||||||
assert result.exit_code == 0
|
|
||||||
|
|
||||||
time.sleep(2) # Wait for the stream to start
|
|
||||||
|
|
||||||
if active:
|
if active:
|
||||||
assert 'Streaming is already in progress, cannot start.' in result.stdout
|
assert result.exit_code != 0
|
||||||
|
assert 'Streaming is already in progress, cannot start.' in result.stderr
|
||||||
else:
|
else:
|
||||||
|
assert result.exit_code == 0
|
||||||
assert 'Streaming started successfully.' in result.stdout
|
assert 'Streaming started successfully.' in result.stdout
|
||||||
|
time.sleep(1) # Wait for the streaming to start
|
||||||
|
|
||||||
|
|
||||||
def test_stream_stop():
|
def test_stream_stop():
|
||||||
@ -33,14 +33,14 @@ def test_stream_stop():
|
|||||||
active = 'Streaming is in progress' in result.stdout
|
active = 'Streaming is in progress' in result.stdout
|
||||||
|
|
||||||
result = runner.invoke(app, ['stream', 'stop'])
|
result = runner.invoke(app, ['stream', 'stop'])
|
||||||
assert result.exit_code == 0
|
|
||||||
|
|
||||||
time.sleep(2) # Wait for the stream to stop
|
|
||||||
|
|
||||||
if active:
|
if active:
|
||||||
|
assert result.exit_code == 0
|
||||||
assert 'Streaming stopped successfully.' in result.stdout
|
assert 'Streaming stopped successfully.' in result.stdout
|
||||||
|
time.sleep(1) # Wait for the streaming to stop
|
||||||
else:
|
else:
|
||||||
assert 'Streaming is not in progress, cannot stop.' in result.stdout
|
assert result.exit_code != 0
|
||||||
|
assert 'Streaming is not in progress, cannot stop.' in result.stderr
|
||||||
|
|
||||||
|
|
||||||
def test_stream_toggle():
|
def test_stream_toggle():
|
||||||
@ -52,7 +52,7 @@ def test_stream_toggle():
|
|||||||
result = runner.invoke(app, ['stream', 'toggle'])
|
result = runner.invoke(app, ['stream', 'toggle'])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
time.sleep(2) # Wait for the stream to toggle
|
time.sleep(1) # Wait for the stream to toggle
|
||||||
|
|
||||||
if active:
|
if active:
|
||||||
assert 'Streaming stopped successfully.' in result.stdout
|
assert 'Streaming stopped successfully.' in result.stdout
|
||||||
|
Loading…
x
Reference in New Issue
Block a user