diff --git a/tests/test_record.py b/tests/test_record.py index 4346afa..2f6d490 100644 --- a/tests/test_record.py +++ b/tests/test_record.py @@ -49,7 +49,9 @@ def test_record_toggle(): result = runner.invoke(app, ['record', 'toggle']) assert result.exit_code == 0 + time.sleep(0.5) # Wait for the recording to toggle + if active: assert 'Recording stopped successfully.' in result.stdout else: diff --git a/tests/test_replaybuffer.py b/tests/test_replaybuffer.py index a30d872..5d9009a 100644 --- a/tests/test_replaybuffer.py +++ b/tests/test_replaybuffer.py @@ -1,6 +1,7 @@ """Unit tests for the replaybuffer command in the OBS WebSocket CLI.""" import os +import time import pytest from typer.testing import CliRunner @@ -23,6 +24,9 @@ def test_replaybuffer_start(): active = 'Replay buffer is active.' in resp.stdout resp = runner.invoke(app, ['replaybuffer', 'start']) + + time.sleep(0.5) # Wait for the replay buffer to start + if active: assert resp.exit_code != 0 assert 'Replay buffer is already active.' in resp.stderr @@ -38,6 +42,9 @@ def test_replaybuffer_stop(): active = 'Replay buffer is active.' in resp.stdout resp = runner.invoke(app, ['replaybuffer', 'stop']) + + time.sleep(0.5) # Wait for the replay buffer to stop + if not active: assert resp.exit_code != 0 assert 'Replay buffer is not active.' in resp.stderr @@ -53,9 +60,11 @@ def test_replaybuffer_toggle(): active = 'Replay buffer is active.' in resp.stdout resp = runner.invoke(app, ['replaybuffer', 'toggle']) + assert resp.exit_code == 0 + + time.sleep(0.5) # Wait for the replay buffer to 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 diff --git a/tests/test_stream.py b/tests/test_stream.py index c15cdb3..ddf7f0a 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -23,7 +23,7 @@ def test_stream_start(): else: assert result.exit_code == 0 assert 'Streaming started successfully.' in result.stdout - time.sleep(1) # Wait for the streaming to start + time.sleep(0.5) # Wait for the streaming to start def test_stream_stop(): @@ -37,7 +37,7 @@ def test_stream_stop(): if active: assert result.exit_code == 0 assert 'Streaming stopped successfully.' in result.stdout - time.sleep(1) # Wait for the streaming to stop + time.sleep(0.5) # Wait for the streaming to stop else: assert result.exit_code != 0 assert 'Streaming is not in progress, cannot stop.' in result.stderr @@ -52,7 +52,7 @@ def test_stream_toggle(): result = runner.invoke(app, ['stream', 'toggle']) assert result.exit_code == 0 - time.sleep(1) # Wait for the stream to toggle + time.sleep(0.5) # Wait for the stream to toggle if active: assert 'Streaming stopped successfully.' in result.stdout