mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2025-06-27 15:20:24 +01:00
add pre_test script
ensure teardown removes the test scenes
This commit is contained in:
parent
e7a561c7b4
commit
377a9df824
@ -27,6 +27,7 @@ path = "src/slobs_cli/__about__.py"
|
|||||||
cli.cmd = "slobs-cli {args}"
|
cli.cmd = "slobs-cli {args}"
|
||||||
cli.env_file = ".env"
|
cli.env_file = ".env"
|
||||||
|
|
||||||
|
pre_test.cmd = "python tests/setup.py"
|
||||||
test.cmd = "pytest {args}"
|
test.cmd = "pytest {args}"
|
||||||
test.env_file = ".env"
|
test.env_file = ".env"
|
||||||
post_test.cmd = "python tests/teardown.py"
|
post_test.cmd = "python tests/teardown.py"
|
||||||
|
32
tests/setup.py
Normal file
32
tests/setup.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import anyio
|
||||||
|
from anyio import create_task_group
|
||||||
|
from pyslobs import ConnectionConfig, ScenesService, SlobsConnection
|
||||||
|
|
||||||
|
|
||||||
|
async def setup(conn: SlobsConnection):
|
||||||
|
ss = ScenesService(conn)
|
||||||
|
await ss.create_scene("slobs-test-scene-1")
|
||||||
|
await ss.create_scene("slobs-test-scene-2")
|
||||||
|
await ss.create_scene("slobs-test-scene-3")
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
conn = SlobsConnection(
|
||||||
|
ConnectionConfig(
|
||||||
|
domain=os.environ["SLOBS_DOMAIN"],
|
||||||
|
port=59650,
|
||||||
|
token=os.environ["SLOBS_TOKEN"],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
async with create_task_group() as tg:
|
||||||
|
tg.start_soon(conn.background_processing)
|
||||||
|
tg.start_soon(setup, conn)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
anyio.run(main)
|
@ -2,10 +2,16 @@ import os
|
|||||||
|
|
||||||
import anyio
|
import anyio
|
||||||
from anyio import create_task_group
|
from anyio import create_task_group
|
||||||
from pyslobs import ConnectionConfig, SlobsConnection, StreamingService
|
from pyslobs import ConnectionConfig, ScenesService, SlobsConnection, StreamingService
|
||||||
|
|
||||||
|
|
||||||
async def cleanup(conn: SlobsConnection):
|
async def cleanup(conn: SlobsConnection):
|
||||||
|
ss = ScenesService(conn)
|
||||||
|
scenes = await ss.get_scenes()
|
||||||
|
for scene in scenes:
|
||||||
|
if scene.name.startswith("slobs-test-scene-"):
|
||||||
|
await ss.remove_scene(scene.id)
|
||||||
|
|
||||||
ss = StreamingService(conn)
|
ss = StreamingService(conn)
|
||||||
current_state = await ss.get_model()
|
current_state = await ss.get_model()
|
||||||
if current_state.streaming_status != "offline":
|
if current_state.streaming_status != "offline":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user