mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2024-11-15 17:10:46 +00:00
add sync kwarg, reformat tests.
tests reformatted, add sync to tests. add sync kwarg to vbancmd. Set for apply_profile.
This commit is contained in:
parent
b7b62ea2fe
commit
1c0ebfa1d1
@ -1,22 +1,22 @@
|
||||
import vbancmd
|
||||
from vbancmd import kinds
|
||||
from vbancmd.channel import Modes
|
||||
import socket
|
||||
from threading import Thread
|
||||
|
||||
_kind = 'potato'
|
||||
_kind = "potato"
|
||||
opts = {
|
||||
'ip': 'ws.local',
|
||||
'streamname': 'testing',
|
||||
'port': 6990,
|
||||
'bps': 0,
|
||||
"ip": "ws.local",
|
||||
"streamname": "testing",
|
||||
"port": 6990,
|
||||
"bps": 0,
|
||||
"sync": True,
|
||||
}
|
||||
|
||||
vbanrs = {kind.id: vbancmd.connect(_kind, **opts) for kind in kinds.all}
|
||||
tests = vbanrs[_kind]
|
||||
|
||||
|
||||
def setup_package():
|
||||
tests.login()
|
||||
|
||||
|
||||
def teardown_package():
|
||||
tests.logout()
|
||||
|
@ -4,15 +4,20 @@ from parameterized import parameterized, parameterized_class
|
||||
import unittest
|
||||
from tests import tests
|
||||
|
||||
#@nottest
|
||||
@parameterized_class([
|
||||
{ "val": False }, { "val": True }
|
||||
])
|
||||
# @nottest
|
||||
@parameterized_class([{"val": False}, {"val": True}])
|
||||
class TestSetAndGetBoolHigher(unittest.TestCase):
|
||||
""" strip tests, physical and virtual """
|
||||
@parameterized.expand([
|
||||
(0, 'mute'), (2, 'mono'), (3, 'A1'), (6, 'B3'), (6, 'mute'),
|
||||
])
|
||||
"""strip tests, physical and virtual"""
|
||||
|
||||
@parameterized.expand(
|
||||
[
|
||||
(0, "mute"),
|
||||
(2, "mono"),
|
||||
(3, "A1"),
|
||||
(6, "B3"),
|
||||
(6, "mute"),
|
||||
]
|
||||
)
|
||||
def test_it_sets_and_gets_strip_bool_params(self, index, param):
|
||||
setattr(tests.strip[index], param, self.val)
|
||||
retval = getattr(tests.strip[index], param)
|
||||
@ -20,9 +25,10 @@ class TestSetAndGetBoolHigher(unittest.TestCase):
|
||||
assert_equal(retval, self.val)
|
||||
|
||||
""" bus tests, physical and virtual """
|
||||
@parameterized.expand([
|
||||
(0, 'mute'), (2, 'mono'), (6, 'mute'), (2, 'eq'), (7, 'eq_ab')
|
||||
])
|
||||
|
||||
@parameterized.expand(
|
||||
[(0, "mute"), (2, "mono"), (6, "mute"), (2, "eq"), (7, "eq_ab")]
|
||||
)
|
||||
def test_it_sets_and_gets_bus_bool_params(self, index, param):
|
||||
setattr(tests.bus[index], param, self.val)
|
||||
retval = getattr(tests.bus[index], param)
|
||||
@ -30,10 +36,19 @@ class TestSetAndGetBoolHigher(unittest.TestCase):
|
||||
assert_equal(retval, self.val)
|
||||
|
||||
""" bus mode tests, physical and virtual """
|
||||
@parameterized.expand([
|
||||
(0, 'amix'), (0, 'tvmix'), (2, 'composite'), (2, 'upmix41'),
|
||||
(7, 'upmix21'), (7, 'rearonly'), (6, 'lfeonly'), (6, 'repeat')
|
||||
])
|
||||
|
||||
@parameterized.expand(
|
||||
[
|
||||
(0, "amix"),
|
||||
(0, "tvmix"),
|
||||
(2, "composite"),
|
||||
(2, "upmix41"),
|
||||
(7, "upmix21"),
|
||||
(7, "rearonly"),
|
||||
(6, "lfeonly"),
|
||||
(6, "repeat"),
|
||||
]
|
||||
)
|
||||
def test_it_sets_and_gets_bus_mode_bool_params(self, index, param):
|
||||
setattr(tests.bus[index].mode, param, self.val)
|
||||
retval = getattr(tests.bus[index].mode, param)
|
||||
@ -41,43 +56,39 @@ class TestSetAndGetBoolHigher(unittest.TestCase):
|
||||
assert_equal(retval, self.val)
|
||||
|
||||
|
||||
#@nottest
|
||||
@parameterized_class([
|
||||
{ "val": "test0" }, { "val": "test1" }
|
||||
])
|
||||
# @nottest
|
||||
@parameterized_class([{"val": "test0"}, {"val": "test1"}, {"val": ""}])
|
||||
class TestSetAndGetStringHigher(unittest.TestCase):
|
||||
""" strip tests, physical and virtual """
|
||||
@parameterized.expand([
|
||||
(2, 'label'), (6, 'label')
|
||||
])
|
||||
"""strip tests, physical and virtual"""
|
||||
|
||||
@parameterized.expand([(2, "label"), (6, "label")])
|
||||
def test_it_sets_and_gets_strip_string_params(self, index, param):
|
||||
setattr(tests.strip[index], param, self.val)
|
||||
assert_equal(getattr(tests.strip[index], param), self.val)
|
||||
|
||||
""" bus tests, physical and virtual """
|
||||
@parameterized.expand([
|
||||
(0, 'label'), (7, 'label')
|
||||
])
|
||||
|
||||
@parameterized.expand([(0, "label"), (7, "label")])
|
||||
def test_it_sets_and_gets_bus_string_params(self, index, param):
|
||||
setattr(tests.bus[index], param, self.val)
|
||||
assert_equal(getattr(tests.bus[index], param), self.val)
|
||||
|
||||
|
||||
#@nottest
|
||||
# @nottest
|
||||
class TestSetAndGetFloatHigher(unittest.TestCase):
|
||||
""" strip tests, physical and virtual """
|
||||
@parameterized.expand([
|
||||
(0, 1, 'gain', -6.3), (7, 4, 'gain', -12.5), (3, 3, 'gain', 3.3)
|
||||
])
|
||||
"""strip tests, physical and virtual"""
|
||||
|
||||
@parameterized.expand(
|
||||
[(0, 1, "gain", -6.3), (7, 4, "gain", -12.5), (3, 3, "gain", 3.3)]
|
||||
)
|
||||
def test_it_sets_and_gets_strip_float_params(self, index, j, param, val):
|
||||
setattr(tests.strip[index].gainlayer[j], param, val)
|
||||
retval = getattr(tests.strip[index].gainlayer[j], param)
|
||||
assert_equal(retval, val)
|
||||
|
||||
""" bus tests, physical and virtual """
|
||||
@parameterized.expand([
|
||||
(0, 'gain', -6.3), (7, 'gain', -12.5), (3, 'gain', 3.3)
|
||||
])
|
||||
|
||||
@parameterized.expand([(0, "gain", -6.3), (7, "gain", -12.5), (3, "gain", 3.3)])
|
||||
def test_it_sets_and_gets_bus_float_params(self, index, param, val):
|
||||
setattr(tests.bus[index], param, val)
|
||||
retval = getattr(tests.bus[index], param)
|
||||
|
@ -2,28 +2,48 @@ from nose.tools import assert_equal, nottest
|
||||
from parameterized import parameterized, parameterized_class
|
||||
|
||||
import unittest
|
||||
from vbancmd.channel import Modes
|
||||
from tests import tests
|
||||
|
||||
#@nottest
|
||||
@parameterized_class([
|
||||
{ "val": 0 }, { "val": 1 },
|
||||
])
|
||||
# @nottest
|
||||
@parameterized_class(
|
||||
[
|
||||
{"val": 0},
|
||||
{"val": 1},
|
||||
]
|
||||
)
|
||||
class TestSetAndGetParamsLower(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
tests._modes = Modes()
|
||||
|
||||
""" get_rt, set_rt test """
|
||||
@parameterized.expand([
|
||||
(0, 'mute'), (4, 'mute'),
|
||||
])
|
||||
|
||||
@parameterized.expand(
|
||||
[
|
||||
(0, "mute"),
|
||||
(4, "mute"),
|
||||
]
|
||||
)
|
||||
def test_it_sets_and_gets_strip_bool_params(self, index, param):
|
||||
tests.set_rt(f'Strip[{index}]', param, self.val)
|
||||
tests.set_rt(f"Strip[{index}]", param, self.val)
|
||||
retval = tests._get_rt()
|
||||
retval = not int.from_bytes(retval.stripstate[index], 'little') & tests._modes._mute == 0
|
||||
retval = (
|
||||
not int.from_bytes(retval.stripstate[index], "little") & tests._modes._mute
|
||||
== 0
|
||||
)
|
||||
assert_equal(retval, self.val)
|
||||
|
||||
@parameterized.expand([
|
||||
(0, 'mono'), (5, 'mono'),
|
||||
])
|
||||
@parameterized.expand(
|
||||
[
|
||||
(0, "mono"),
|
||||
(5, "mono"),
|
||||
]
|
||||
)
|
||||
def test_it_sets_and_gets_strip_bool_params(self, index, param):
|
||||
tests.set_rt(f'Strip[{index}]', param, self.val)
|
||||
tests.set_rt(f"Strip[{index}]", param, self.val)
|
||||
retval = tests._get_rt()
|
||||
retval = not int.from_bytes(retval.stripstate[index], 'little') & tests._modes._mono == 0
|
||||
retval = (
|
||||
not int.from_bytes(retval.stripstate[index], "little") & tests._modes._mono
|
||||
== 0
|
||||
)
|
||||
assert_equal(retval, self.val)
|
||||
|
@ -29,6 +29,7 @@ class VbanCmd(abc.ABC):
|
||||
self._channel = kwargs["channel"]
|
||||
self._delay = kwargs["delay"]
|
||||
self._ratelimiter = kwargs["ratelimiter"]
|
||||
self._sync = kwargs["sync"]
|
||||
# fmt: off
|
||||
self._bps_opts = [
|
||||
0, 110, 150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 31250,
|
||||
@ -196,7 +197,8 @@ class VbanCmd(abc.ABC):
|
||||
count = int.from_bytes(self._text_header.framecounter, "little") + 1
|
||||
self._text_header.framecounter = count.to_bytes(4, "little")
|
||||
self.cache[f"{id_}.{param}"] = [val, True]
|
||||
sleep(self._ratelimiter)
|
||||
if self._sync:
|
||||
sleep(self._ratelimiter)
|
||||
|
||||
def sendtext(self, cmd):
|
||||
"""Sends a multiple parameter string over a network."""
|
||||
@ -243,6 +245,7 @@ class VbanCmd(abc.ABC):
|
||||
target.apply(submapping)
|
||||
|
||||
def apply_profile(self, name: str):
|
||||
self._sync = True
|
||||
try:
|
||||
profile = self.profiles[name]
|
||||
if "extends" in profile:
|
||||
@ -257,6 +260,7 @@ class VbanCmd(abc.ABC):
|
||||
self.apply(profile)
|
||||
except KeyError:
|
||||
raise VMCMDErrors(f"Unknown profile: {self.kind.id}/{name}")
|
||||
self._sync = False
|
||||
|
||||
def reset(self) -> NoReturn:
|
||||
self.apply_profile("base")
|
||||
@ -290,6 +294,7 @@ def _make_remote(kind: NamedTuple) -> VbanCmd:
|
||||
"channel": 0,
|
||||
"delay": 0.001,
|
||||
"ratelimiter": 0.018,
|
||||
"sync": False,
|
||||
}
|
||||
kwargs = defaultkwargs | kwargs
|
||||
VbanCmd.__init__(self, **kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user