mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2024-11-22 12:50:53 +00:00
added test_attrs
added tests to test_request keys in attrs() list now snake cased
This commit is contained in:
parent
ce9bc7e8d6
commit
e145362726
@ -8,7 +8,7 @@ import tomllib
|
||||
import websocket
|
||||
|
||||
|
||||
class ObsClient(object):
|
||||
class ObsClient:
|
||||
DELAY = 0.001
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
@ -19,7 +19,7 @@ Subs = IntEnum(
|
||||
)
|
||||
|
||||
|
||||
class EventClient(object):
|
||||
class EventClient:
|
||||
DELAY = 0.001
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
@ -9,7 +9,7 @@ https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.
|
||||
"""
|
||||
|
||||
|
||||
class ReqClient(object):
|
||||
class ReqClient:
|
||||
def __init__(self, **kwargs):
|
||||
self.base_client = ObsClient(**kwargs)
|
||||
self.base_client.authenticate()
|
||||
|
@ -12,7 +12,7 @@ def to_snake_case(s):
|
||||
|
||||
def as_dataclass(identifier, data):
|
||||
def attrs():
|
||||
return list(data.keys())
|
||||
return list(to_snake_case(k) for k in data.keys())
|
||||
|
||||
return dataclass(
|
||||
type(
|
||||
|
27
tests/test_attrs.py
Normal file
27
tests/test_attrs.py
Normal file
@ -0,0 +1,27 @@
|
||||
import pytest
|
||||
|
||||
from tests import req_cl
|
||||
|
||||
|
||||
class TestAttrs:
|
||||
__test__ = True
|
||||
|
||||
def test_get_version_attrs(self):
|
||||
resp = req_cl.get_version()
|
||||
assert resp.attrs() == [
|
||||
"available_requests",
|
||||
"obs_version",
|
||||
"obs_web_socket_version",
|
||||
"platform",
|
||||
"platform_description",
|
||||
"rpc_version",
|
||||
"supported_image_formats",
|
||||
]
|
||||
|
||||
def test_get_current_program_scene_attrs(self):
|
||||
resp = req_cl.get_current_program_scene()
|
||||
assert resp.attrs() == ["current_program_scene_name"]
|
||||
|
||||
def test_get_transition_kind_list_attrs(self):
|
||||
resp = req_cl.get_transition_kind_list()
|
||||
assert resp.attrs() == ["transition_kinds"]
|
@ -36,6 +36,53 @@ class TestRequests:
|
||||
resp = req_cl.get_studio_mode_enabled()
|
||||
assert resp.studio_mode_enabled == state
|
||||
|
||||
def test_get_hot_key_list(self):
|
||||
resp = req_cl.get_hot_key_list()
|
||||
hotkey_list = [
|
||||
"OBSBasic.StartStreaming",
|
||||
"OBSBasic.StopStreaming",
|
||||
"OBSBasic.ForceStopStreaming",
|
||||
"OBSBasic.StartRecording",
|
||||
"OBSBasic.StopRecording",
|
||||
"OBSBasic.PauseRecording",
|
||||
"OBSBasic.UnpauseRecording",
|
||||
"OBSBasic.StartReplayBuffer",
|
||||
"OBSBasic.StopReplayBuffer",
|
||||
"OBSBasic.StartVirtualCam",
|
||||
"OBSBasic.StopVirtualCam",
|
||||
"OBSBasic.EnablePreview",
|
||||
"OBSBasic.DisablePreview",
|
||||
"OBSBasic.ShowContextBar",
|
||||
"OBSBasic.HideContextBar",
|
||||
"OBSBasic.TogglePreviewProgram",
|
||||
"OBSBasic.Transition",
|
||||
"OBSBasic.ResetStats",
|
||||
"OBSBasic.Screenshot",
|
||||
"OBSBasic.SelectedSourceScreenshot",
|
||||
"libobs.mute",
|
||||
"libobs.unmute",
|
||||
"libobs.push-to-mute",
|
||||
"libobs.push-to-talk",
|
||||
"libobs.mute",
|
||||
"libobs.unmute",
|
||||
"libobs.push-to-mute",
|
||||
"libobs.push-to-talk",
|
||||
"OBSBasic.SelectScene",
|
||||
"OBSBasic.SelectScene",
|
||||
"OBSBasic.SelectScene",
|
||||
"OBSBasic.SelectScene",
|
||||
"libobs.show_scene_item.Colour Source 2",
|
||||
"libobs.hide_scene_item.Colour Source 2",
|
||||
"libobs.show_scene_item.Colour Source 3",
|
||||
"libobs.hide_scene_item.Colour Source 3",
|
||||
"libobs.show_scene_item.Colour Source",
|
||||
"libobs.hide_scene_item.Colour Source",
|
||||
"OBSBasic.QuickTransition.1",
|
||||
"OBSBasic.QuickTransition.2",
|
||||
"OBSBasic.QuickTransition.3",
|
||||
]
|
||||
assert all(x in resp.hotkeys for x in hotkey_list)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"name,data",
|
||||
[
|
||||
@ -47,3 +94,25 @@ class TestRequests:
|
||||
req_cl.set_persistent_data("OBS_WEBSOCKET_DATA_REALM_PROFILE", name, data)
|
||||
resp = req_cl.get_persistent_data("OBS_WEBSOCKET_DATA_REALM_PROFILE", name)
|
||||
assert resp.slot_value == data
|
||||
|
||||
def test_profile_list(self):
|
||||
req_cl.create_profile("test")
|
||||
resp = req_cl.get_profile_list()
|
||||
assert "test" in resp.profiles
|
||||
req_cl.remove_profile("test")
|
||||
resp = req_cl.get_profile_list()
|
||||
assert "test" not in resp.profiles
|
||||
|
||||
def test_source_filter(self):
|
||||
req_cl.create_source_filter("START", "test", "color_key_filter_v2")
|
||||
resp = req_cl.get_source_filter_list("START")
|
||||
assert resp.filters == [
|
||||
{
|
||||
"filterEnabled": True,
|
||||
"filterIndex": 0,
|
||||
"filterKind": "color_key_filter_v2",
|
||||
"filterName": "test",
|
||||
"filterSettings": {},
|
||||
}
|
||||
]
|
||||
req_cl.remove_source_filter("START", "test")
|
||||
|
Loading…
Reference in New Issue
Block a user