mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2026-04-18 14:03:32 +00:00
add callback unit tests.
callback deregister now accepts iterable.
This commit is contained in:
59
tests/test_callback.py
Normal file
59
tests/test_callback.py
Normal file
@@ -0,0 +1,59 @@
|
||||
import pytest
|
||||
from obsstudio_sdk.callback import Callback
|
||||
|
||||
|
||||
class TestCallbacks:
|
||||
__test__ = True
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
cls.callback = Callback()
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def wraps_tests(self):
|
||||
yield
|
||||
self.callback.clear()
|
||||
|
||||
def test_register_callback(self):
|
||||
def on_callback_method():
|
||||
pass
|
||||
|
||||
self.callback.register(on_callback_method)
|
||||
assert self.callback.get() == ["CallbackMethod"]
|
||||
|
||||
def test_register_callbacks(self):
|
||||
def on_callback_method_one():
|
||||
pass
|
||||
|
||||
def on_callback_method_two():
|
||||
pass
|
||||
|
||||
self.callback.register((on_callback_method_one, on_callback_method_two))
|
||||
assert self.callback.get() == ["CallbackMethodOne", "CallbackMethodTwo"]
|
||||
|
||||
def test_deregister_callback(self):
|
||||
def on_callback_method_one():
|
||||
pass
|
||||
|
||||
def on_callback_method_two():
|
||||
pass
|
||||
|
||||
self.callback.register((on_callback_method_one, on_callback_method_two))
|
||||
self.callback.deregister(on_callback_method_one)
|
||||
assert self.callback.get() == ["CallbackMethodTwo"]
|
||||
|
||||
def test_deregister_callbacks(self):
|
||||
def on_callback_method_one():
|
||||
pass
|
||||
|
||||
def on_callback_method_two():
|
||||
pass
|
||||
|
||||
def on_callback_method_three():
|
||||
pass
|
||||
|
||||
self.callback.register(
|
||||
(on_callback_method_one, on_callback_method_two, on_callback_method_three)
|
||||
)
|
||||
self.callback.deregister((on_callback_method_two, on_callback_method_three))
|
||||
assert self.callback.get() == ["CallbackMethodOne"]
|
||||
@@ -1,5 +1,3 @@
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from tests import req_cl
|
||||
|
||||
Reference in New Issue
Block a user