mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2025-08-03 10:31:46 +00:00
tests should now pass from fresh install
This commit is contained in:
parent
f852a733c3
commit
e851219ced
@ -1,6 +1,7 @@
|
||||
"""pytest configuration file."""
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
import obsws_python as obsws
|
||||
from dotenv import find_dotenv, load_dotenv
|
||||
@ -44,9 +45,54 @@ def pytest_sessionstart(session):
|
||||
},
|
||||
)
|
||||
|
||||
session.obsws.set_current_scene_collection('test-collection')
|
||||
|
||||
session.obsws.create_profile('pytest_profile')
|
||||
time.sleep(0.1) # Wait for the profile to be created
|
||||
session.obsws.set_profile_parameter(
|
||||
'SimpleOutput',
|
||||
'RecRB',
|
||||
'true',
|
||||
)
|
||||
# hack to ensure the replay buffer is enabled
|
||||
session.obsws.set_current_profile('Untitled')
|
||||
session.obsws.set_current_profile('pytest_profile')
|
||||
session.obsws.create_scene('pytest_scene')
|
||||
|
||||
# Ensure Desktop Audio is created.
|
||||
desktop_audio_kinds = {
|
||||
'windows': 'wasapi_output_capture',
|
||||
'linux': 'pulse_output_capture',
|
||||
'darwin': 'coreaudio_output_capture',
|
||||
}
|
||||
platform = os.environ.get('OBS_TESTS_PLATFORM', os.uname().sysname.lower())
|
||||
try:
|
||||
session.obsws.create_input(
|
||||
sceneName='pytest_scene',
|
||||
inputName='Desktop Audio',
|
||||
inputKind=desktop_audio_kinds[platform],
|
||||
inputSettings={'device_id': 'default'},
|
||||
sceneItemEnabled=True,
|
||||
)
|
||||
except obsws.error.OBSSDKRequestError as e:
|
||||
if e.code == 601:
|
||||
"""input already exists, continue."""
|
||||
# Ensure Mic/Aux is created.
|
||||
mic_kinds = {
|
||||
'windows': 'wasapi_input_capture',
|
||||
'linux': 'pulse_input_capture',
|
||||
'darwin': 'coreaudio_input_capture',
|
||||
}
|
||||
try:
|
||||
session.obsws.create_input(
|
||||
sceneName='pytest_scene',
|
||||
inputName='Mic/Aux',
|
||||
inputKind=mic_kinds[platform],
|
||||
inputSettings={'device_id': 'default'},
|
||||
sceneItemEnabled=True,
|
||||
)
|
||||
except obsws.error.OBSSDKRequestError as e:
|
||||
if e.code == 601:
|
||||
"""input already exists, continue."""
|
||||
|
||||
session.obsws.create_input(
|
||||
sceneName='pytest_scene',
|
||||
inputName='pytest_input',
|
||||
@ -131,7 +177,7 @@ def pytest_sessionfinish(session, exitstatus):
|
||||
|
||||
session.obsws.remove_scene('pytest_scene')
|
||||
|
||||
session.obsws.set_current_scene_collection('default')
|
||||
session.obsws.set_current_scene_collection('Untitled')
|
||||
|
||||
resp = session.obsws.get_stream_status()
|
||||
if resp.output_active:
|
||||
@ -149,6 +195,8 @@ def pytest_sessionfinish(session, exitstatus):
|
||||
if resp.studio_mode_enabled:
|
||||
session.obsws.set_studio_mode_enabled(False)
|
||||
|
||||
session.obsws.remove_profile('pytest_profile')
|
||||
|
||||
# Close the OBS WebSocket client connection
|
||||
session.obsws.disconnect()
|
||||
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_filter_list():
|
||||
|
@ -1,10 +1,18 @@
|
||||
"""Unit tests for the group command in the OBS WebSocket CLI."""
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
if os.environ.get('OBS_TESTS_SKIP_GROUP_TESTS'):
|
||||
pytest.skip(
|
||||
'Skipping group tests as per environment variable', allow_module_level=True
|
||||
)
|
||||
|
||||
|
||||
def test_group_list():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_hotkey_list():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_input_list():
|
||||
@ -13,10 +13,7 @@ def test_input_list():
|
||||
assert result.exit_code == 0
|
||||
assert 'Desktop Audio' in result.stdout
|
||||
assert 'Mic/Aux' in result.stdout
|
||||
assert all(
|
||||
item in result.stdout
|
||||
for item in ('Colour Source', 'Colour Source 2', 'Colour Source 3')
|
||||
)
|
||||
assert all(item in result.stdout for item in ('pytest_input', 'pytest_input_2'))
|
||||
|
||||
|
||||
def test_input_list_filter_input():
|
||||
@ -39,9 +36,6 @@ def test_input_list_filter_colour():
|
||||
"""Test the input list command with colour filter."""
|
||||
result = runner.invoke(app, ['input', 'list', '--colour'])
|
||||
assert result.exit_code == 0
|
||||
assert all(
|
||||
item in result.stdout
|
||||
for item in ('Colour Source', 'Colour Source 2', 'Colour Source 3')
|
||||
)
|
||||
assert all(item in result.stdout for item in ('pytest_input', 'pytest_input_2'))
|
||||
assert 'Desktop Audio' not in result.stdout
|
||||
assert 'Mic/Aux' not in result.stdout
|
||||
|
@ -6,7 +6,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_record_start():
|
||||
|
@ -1,10 +1,19 @@
|
||||
"""Unit tests for the replaybuffer command in the OBS WebSocket CLI."""
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
if os.environ.get('OBS_TESTS_SKIP_REPLAYBUFFER_TESTS'):
|
||||
pytest.skip(
|
||||
'Skipping replaybuffer tests as per environment variable',
|
||||
allow_module_level=True,
|
||||
)
|
||||
|
||||
|
||||
def test_replaybuffer_start():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_scene_list():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_sceneitem_list():
|
||||
|
@ -6,7 +6,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_stream_start():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_studio_enable():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_text_update():
|
||||
|
@ -4,7 +4,7 @@ from typer.testing import CliRunner
|
||||
|
||||
from obsws_cli.app import app
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_version():
|
||||
|
Loading…
x
Reference in New Issue
Block a user