mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2026-04-05 16:39:10 +00:00
125 lines
4.1 KiB
Python
125 lines
4.1 KiB
Python
import pytest
|
|
|
|
from tests import req_cl
|
|
|
|
|
|
class TestRequests:
|
|
__test__ = True
|
|
|
|
def test_get_version(self):
|
|
resp = req_cl.get_version()
|
|
assert hasattr(resp, "obs_version")
|
|
assert hasattr(resp, "obs_web_socket_version")
|
|
|
|
def test_get_hotkey_list(self):
|
|
resp = req_cl.get_hotkey_list()
|
|
assert resp.hotkeys
|
|
assert any(x.startswith("OBSBasic.") for x in resp.hotkeys)
|
|
|
|
@pytest.mark.parametrize(
|
|
"name,data",
|
|
[
|
|
("val1", 3),
|
|
("val2", "hello"),
|
|
],
|
|
)
|
|
def test_persistent_data(self, name, data):
|
|
req_cl.set_persistent_data(
|
|
realm="OBS_WEBSOCKET_DATA_REALM_PROFILE", slot_name=name, slot_value=data
|
|
)
|
|
resp = req_cl.get_persistent_data(
|
|
realm="OBS_WEBSOCKET_DATA_REALM_PROFILE", slot_name=name
|
|
)
|
|
assert resp.slot_value == data
|
|
|
|
@pytest.mark.skip(reason="possible bug in obs-websocket, needs checking")
|
|
def test_profile_list(self):
|
|
req_cl.create_profile(profile_name="test")
|
|
resp = req_cl.get_profile_list()
|
|
assert "test" in resp.profiles
|
|
req_cl.remove_profile(profile_name="test")
|
|
resp = req_cl.get_profile_list()
|
|
assert "test" not in resp.profiles
|
|
|
|
def test_stream_service_settings(self):
|
|
settings = {
|
|
"server": "rtmp://addressofrtmpserver",
|
|
"key": "live_myvery_secretkey",
|
|
}
|
|
req_cl.set_stream_service_settings(
|
|
stream_service_type="rtmp_common",
|
|
stream_service_settings=settings,
|
|
)
|
|
resp = req_cl.get_stream_service_settings()
|
|
assert resp.stream_service_type == "rtmp_common"
|
|
assert resp.stream_service_settings == {
|
|
"server": "rtmp://addressofrtmpserver",
|
|
"key": "live_myvery_secretkey",
|
|
}
|
|
|
|
@pytest.mark.parametrize(
|
|
"scene",
|
|
[
|
|
("START_TEST"),
|
|
("BRB_TEST"),
|
|
("END_TEST"),
|
|
],
|
|
)
|
|
def test_current_program_scene(self, scene):
|
|
req_cl.set_current_program_scene(scene_name=scene)
|
|
resp = req_cl.get_current_program_scene()
|
|
assert resp.current_program_scene_name == scene
|
|
|
|
def test_input_list(self):
|
|
req_cl.create_input(
|
|
scene_name="START_TEST",
|
|
input_name="test",
|
|
input_kind="color_source_v3",
|
|
input_settings={"color": 4294945535},
|
|
scene_item_enabled=True,
|
|
)
|
|
resp = req_cl.get_input_list()
|
|
for input_item in resp.inputs:
|
|
if input_item["inputName"] == "test":
|
|
assert input_item["inputKind"] == "color_source_v3"
|
|
assert input_item["unversionedInputKind"] == "color_source"
|
|
break
|
|
else:
|
|
# This else block is executed if the for loop completes without finding the input_item with inputName "test"
|
|
raise AssertionError("Input with inputName 'test' not found")
|
|
|
|
resp = req_cl.get_input_settings(input_name="test")
|
|
assert resp.input_kind == "color_source_v3"
|
|
assert resp.input_settings == {"color": 4294945535}
|
|
req_cl.remove_input(input_name="test")
|
|
|
|
def test_source_filter(self):
|
|
req_cl.create_source_filter(
|
|
source_name="START_TEST",
|
|
filter_name="test",
|
|
filter_kind="color_key_filter_v2",
|
|
)
|
|
resp = req_cl.get_source_filter_list(source_name="START_TEST")
|
|
assert resp.filters == [
|
|
{
|
|
"filterEnabled": True,
|
|
"filterIndex": 0,
|
|
"filterKind": "color_key_filter_v2",
|
|
"filterName": "test",
|
|
"filterSettings": {},
|
|
}
|
|
]
|
|
req_cl.remove_source_filter(source_name="START_TEST", filter_name="test")
|
|
|
|
@pytest.mark.parametrize(
|
|
"state",
|
|
[
|
|
(False),
|
|
(True),
|
|
],
|
|
)
|
|
def test_studio_mode_enabled(self, state):
|
|
req_cl.set_studio_mode_enabled(studio_mode_enabled=state)
|
|
resp = req_cl.get_studio_mode_enabled()
|
|
assert resp.studio_mode_enabled == state
|