add some higher tests

add first tests
This commit is contained in:
onyx-and-iris 2022-02-25 15:17:05 +00:00
parent 838e3c4999
commit 6e40ceb346
5 changed files with 65 additions and 13 deletions

View File

@ -1,15 +1,9 @@
import vban_cmd
from time import sleep
def test_set_parameter():
def main():
with vban_cmd.connect('potato', ip='ws.local') as vban:
for param in ['A1']:
for i in range(3):
setattr(vban.strip[i], param, True)
print(getattr(vban.strip[i], param))
setattr(vban.strip[i], param, False)
print(getattr(vban.strip[i], param))
pass
if __name__ == '__main__':
test_set_parameter()
main()

17
setup.py Normal file
View File

@ -0,0 +1,17 @@
from setuptools import setup
setup(
name='vban_cmd',
version='0.0.1',
description='VBAN CMD Python API',
packages=['vban_cmd'],
install_requires=[
],
extras_require={
'development': [
'nose',
'randomize',
'parameterized'
]
}
)

17
tests/__init__.py Normal file
View File

@ -0,0 +1,17 @@
import vban_cmd
from vban_cmd import kinds
import socket
from threading import Thread
_kind = 'banana'
vbanrs = {kind.id: vban_cmd.connect(_kind, ip='ws.local') for kind in kinds.all}
tests = vbanrs[_kind]
def setup_package():
tests._rt_packet_socket.bind((socket.gethostbyname(socket.gethostname()), tests._port))
tests.worker = Thread(target=tests._send_register_rt, daemon=True)
tests.worker.start()
def teardown_package():
pass

20
tests/test_higher.py Normal file
View File

@ -0,0 +1,20 @@
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)

View File

@ -94,9 +94,13 @@ class VbanCmd(abc.ABC):
return False
def get_rt(self):
data = False
while not data:
data = self._fetch_rt_packet()
def fget():
data = False
while not data:
data = self._fetch_rt_packet()
return data
for i in range(2):
data = fget()
return data
def set_rt(self, id_, param, val):
@ -125,7 +129,7 @@ def _make_remote(kind: NamedTuple) -> VbanCmd:
def init(self, *args, **kwargs):
defaultkwargs = {
'ip': None, 'port': 6990, 'streamname': 'Command1', 'bps': 0,
'channel': 0, 'delay': 0.03,
'channel': 0, 'delay': 0.001,
}
kwargs = defaultkwargs | kwargs
VbanCmd.__init__(self, *args, **kwargs)