mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2026-04-18 23:13:39 +00:00
add unit tests for record, replaybuffer, scene, stream
This commit is contained in:
50
tests/test_replaybuffer.py
Normal file
50
tests/test_replaybuffer.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import anyio
|
||||
import asyncclick as click
|
||||
import pytest
|
||||
from asyncclick.testing import CliRunner
|
||||
|
||||
from slobs_cli import cli
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_replaybuffer_start():
|
||||
runner = CliRunner()
|
||||
result = await runner.invoke(cli, ["replaybuffer", "status"])
|
||||
assert result.exit_code == 0
|
||||
active = "Replay buffer is currently active." in result.output
|
||||
|
||||
if not active:
|
||||
result = await runner.invoke(cli, ["replaybuffer", "start"])
|
||||
assert result.exit_code == 0
|
||||
assert "Replay buffer started" in result.output
|
||||
await anyio.sleep(1)
|
||||
else:
|
||||
with pytest.raises(ExceptionGroup) as exc_info:
|
||||
result = await runner.invoke(
|
||||
cli, ["replaybuffer", "start"], catch_exceptions=False
|
||||
)
|
||||
assert exc_info.group_contains(
|
||||
click.Abort, match="Replay buffer is already active."
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_replaybuffer_stop():
|
||||
runner = CliRunner()
|
||||
result = await runner.invoke(cli, ["replaybuffer", "status"])
|
||||
assert result.exit_code == 0
|
||||
active = "Replay buffer is currently active." in result.output
|
||||
|
||||
if active:
|
||||
result = await runner.invoke(cli, ["replaybuffer", "stop"])
|
||||
assert result.exit_code == 0
|
||||
assert "Replay buffer stopped" in result.output
|
||||
await anyio.sleep(1)
|
||||
else:
|
||||
with pytest.raises(ExceptionGroup) as exc_info:
|
||||
result = await runner.invoke(
|
||||
cli, ["replaybuffer", "stop"], catch_exceptions=False
|
||||
)
|
||||
assert exc_info.group_contains(
|
||||
click.Abort, match="Replay buffer is already inactive."
|
||||
)
|
||||
Reference in New Issue
Block a user