mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-18 10:30:48 +00:00
add some higher tests
add first tests
This commit is contained in:
parent
838e3c4999
commit
6e40ceb346
12
__main__.py
12
__main__.py
@ -1,15 +1,9 @@
|
|||||||
import vban_cmd
|
import vban_cmd
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
def test_set_parameter():
|
def main():
|
||||||
with vban_cmd.connect('potato', ip='ws.local') as vban:
|
with vban_cmd.connect('potato', ip='ws.local') as vban:
|
||||||
for param in ['A1']:
|
pass
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test_set_parameter()
|
main()
|
||||||
|
17
setup.py
Normal file
17
setup.py
Normal 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
17
tests/__init__.py
Normal 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
20
tests/test_higher.py
Normal 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)
|
@ -94,9 +94,13 @@ class VbanCmd(abc.ABC):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def get_rt(self):
|
def get_rt(self):
|
||||||
data = False
|
def fget():
|
||||||
while not data:
|
data = False
|
||||||
data = self._fetch_rt_packet()
|
while not data:
|
||||||
|
data = self._fetch_rt_packet()
|
||||||
|
return data
|
||||||
|
for i in range(2):
|
||||||
|
data = fget()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def set_rt(self, id_, param, val):
|
def set_rt(self, id_, param, val):
|
||||||
@ -125,7 +129,7 @@ def _make_remote(kind: NamedTuple) -> VbanCmd:
|
|||||||
def init(self, *args, **kwargs):
|
def init(self, *args, **kwargs):
|
||||||
defaultkwargs = {
|
defaultkwargs = {
|
||||||
'ip': None, 'port': 6990, 'streamname': 'Command1', 'bps': 0,
|
'ip': None, 'port': 6990, 'streamname': 'Command1', 'bps': 0,
|
||||||
'channel': 0, 'delay': 0.03,
|
'channel': 0, 'delay': 0.001,
|
||||||
}
|
}
|
||||||
kwargs = defaultkwargs | kwargs
|
kwargs = defaultkwargs | kwargs
|
||||||
VbanCmd.__init__(self, *args, **kwargs)
|
VbanCmd.__init__(self, *args, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user