upd stream/record tests

test different exit codes and outputs according to current stream/record state
This commit is contained in:
2025-05-28 14:28:38 +01:00
parent f8d3ed75cb
commit 5bfd642032
2 changed files with 34 additions and 25 deletions

View File

@@ -9,27 +9,36 @@ from obsws_cli.app import app
runner = CliRunner(mix_stderr=False)
def test_record_start_status_stop():
def test_record_start():
"""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'])
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'])
assert result.exit_code == 0
assert 'Recording stopped successfully. Saved to:' in result.stdout
time.sleep(0.5) # Wait for the recording to stop
result = runner.invoke(app, ['record', 'status'])
assert result.exit_code == 0
assert 'Recording is not in progress.' in result.stdout
if not active:
assert result.exit_code != 0
assert 'Recording is not in progress, cannot stop.' in result.stderr
else:
assert result.exit_code == 0
assert 'Recording stopped successfully.' in result.stdout
time.sleep(0.5) # Wait for the recording to stop
def test_record_toggle():