add unit tests for record, replaybuffer, scene, stream

This commit is contained in:
2025-06-10 17:01:55 +01:00
parent c8eb27d188
commit cc2eda00a5
6 changed files with 213 additions and 0 deletions

46
tests/test_stream.py Normal file
View File

@@ -0,0 +1,46 @@
import anyio
import asyncclick as click
import pytest
from asyncclick.testing import CliRunner
from slobs_cli import cli
@pytest.mark.anyio
async def test_stream_start():
runner = CliRunner()
result = await runner.invoke(cli, ["stream", "status"])
assert result.exit_code == 0
active = "Stream is currently active." in result.output
if not active:
result = await runner.invoke(cli, ["stream", "start"])
assert result.exit_code == 0
assert "Stream started" in result.output
await anyio.sleep(1) # Allow some time for the stream to start
else:
with pytest.raises(ExceptionGroup) as exc_info:
result = await runner.invoke(
cli, ["stream", "start"], catch_exceptions=False
)
assert exc_info.group_contains(click.Abort, match="Stream is already active.")
@pytest.mark.anyio
async def test_stream_stop():
runner = CliRunner()
result = await runner.invoke(cli, ["stream", "status"])
assert result.exit_code == 0
active = "Stream is currently active." in result.output
if active:
result = await runner.invoke(cli, ["stream", "stop"])
assert result.exit_code == 0
assert "Stream stopped" in result.output
await anyio.sleep(1) # Allow some time for the stream to stop
else:
with pytest.raises(ExceptionGroup) as exc_info:
result = await runner.invoke(
cli, ["stream", "stop"], catch_exceptions=False
)
assert exc_info.group_contains(click.Abort, match="Stream is already inactive.")