add some tests, commands and bus class

added a couple of lower tests.

add some string tests to higher tests.

added bus class

add higher commands show, hide, shutdown, restart, version and type
This commit is contained in:
onyx-and-iris
2022-02-25 17:02:27 +00:00
parent 6e40ceb346
commit 364e456c94
6 changed files with 211 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
import vban_cmd
from vban_cmd import kinds
from vban_cmd.channel import Modes
import socket
from threading import Thread
@@ -13,5 +14,7 @@ def setup_package():
tests.worker = Thread(target=tests._send_register_rt, daemon=True)
tests.worker.start()
tests._modes = Modes()
def teardown_package():
pass

42
tests/tests_higher.py Normal file
View File

@@ -0,0 +1,42 @@
from nose.tools import assert_equal, nottest
from parameterized import parameterized, parameterized_class
import unittest
from tests import tests
#@nottest
@parameterized_class([
{ "val": False }, { "val": True }
])
class TestSetAndGetBoolHigher(unittest.TestCase):
""" strip tests, physical and virtual """
@parameterized.expand([
(0, 'mute'), (2, 'mono'), (3, 'A1'), (3, 'B3')
])
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)
self.assertTrue(isinstance(retval, bool))
assert_equal(retval, self.val)
#@nottest
@parameterized_class([
{ "val": "test0" }, { "val": "test1" }
])
class TestSetAndGetStringHigher(unittest.TestCase):
""" strip tests, physical and virtual """
@parameterized.expand([
(2, 'label'), (3, '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'), (4, '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)

29
tests/tests_lower.py Normal file
View File

@@ -0,0 +1,29 @@
from nose.tools import assert_equal, nottest
from parameterized import parameterized, parameterized_class
import unittest
from tests import tests
#@nottest
@parameterized_class([
{ "val": 0 }, { "val": 1 },
])
class TestSetAndGetParamsLower(unittest.TestCase):
""" get_rt, set_rt test """
@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)
retval = tests.get_rt()
retval = not int.from_bytes(retval.stripstate[index], 'little') & tests._modes._mute == 0
assert_equal(retval, self.val)
@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)
retval = tests.get_rt()
retval = not int.from_bytes(retval.stripstate[index], 'little') & tests._modes._mono == 0
assert_equal(retval, self.val)