diff --git a/__main__.py b/__main__.py index e8db578..81d714e 100644 --- a/__main__.py +++ b/__main__.py @@ -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() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4350ba9 --- /dev/null +++ b/setup.py @@ -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' + ] + } +) \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..d132a6b --- /dev/null +++ b/tests/__init__.py @@ -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 diff --git a/tests/test_higher.py b/tests/test_higher.py new file mode 100644 index 0000000..192e218 --- /dev/null +++ b/tests/test_higher.py @@ -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) diff --git a/vban_cmd/vban_cmd.py b/vban_cmd/vban_cmd.py index 0edddb7..2ce6e94 100644 --- a/vban_cmd/vban_cmd.py +++ b/vban_cmd/vban_cmd.py @@ -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)