stip.{comp,gate} tests added to higher

This commit is contained in:
onyx-and-iris 2023-06-25 14:23:39 +01:00
parent 3f5dc7c376
commit df7996a846
5 changed files with 62 additions and 66 deletions

View File

@ -3,23 +3,21 @@ import sys
from dataclasses import dataclass
import vban_cmd
from vban_cmd.kinds import KindId, kinds_all
from vban_cmd.kinds import KindId
from vban_cmd.kinds import request_kind_map as kindmap
# let's keep things random
kind_id = random.choice(tuple(kind_id.name.lower() for kind_id in KindId))
KIND_ID = random.choice(tuple(kind_id.name.lower() for kind_id in KindId))
opts = {
"ip": "ws.local",
"streamname": "workstation",
"ip": "testing.local",
"streamname": "testing",
"port": 6990,
"bps": 0,
"sync": True,
}
vbans = {kind.name: vban_cmd.api(kind.name, **opts) for kind in kinds_all}
tests = vbans[kind_id]
kind = kindmap(kind_id)
vban = vban_cmd.api(KIND_ID, **opts)
kind = kindmap(KIND_ID)
@dataclass
@ -42,9 +40,9 @@ data = Data()
def setup_module():
print(f"\nRunning tests for kind [{data.name}]\n", file=sys.stdout)
tests.login()
tests.command.reset()
vban.login()
vban.command.reset()
def teardown_module():
tests.logout()
vban.logout()

View File

@ -1,8 +1,6 @@
import time
import pytest
from tests import data, tests
from tests import data, vban
class TestSetAndGetBoolHigher:
@ -12,18 +10,18 @@ class TestSetAndGetBoolHigher:
@classmethod
def setup_class(cls):
tests.apply_config("example")
vban.apply_config("example")
def test_it_tests_config_string(self):
assert "PhysStrip" in tests.strip[data.phys_in].label
assert "VirtStrip" in tests.strip[data.virt_in].label
assert "PhysStrip" in vban.strip[data.phys_in].label
assert "VirtStrip" in vban.strip[data.virt_in].label
def test_it_tests_config_bool(self):
assert tests.strip[0].A1 == True
assert vban.strip[0].A1 == True
@pytest.mark.skipif(
"not config.getoption('--run-slow')",
reason="Only run when --run-slow is given",
)
def test_it_tests_config_busmode(self):
assert tests.bus[data.phys_out].mode.get() == "composite"
assert vban.bus[data.phys_out].mode.get() == "composite"

View File

@ -1,6 +1,6 @@
import pytest
from tests import data, tests
from tests import data, vban
class TestRemoteFactories:
@ -11,33 +11,33 @@ class TestRemoteFactories:
reason="Skip test if kind is not basic",
)
def test_it_tests_remote_attrs_for_basic(self):
assert hasattr(tests, "strip")
assert hasattr(tests, "bus")
assert hasattr(tests, "command")
assert hasattr(vban, "strip")
assert hasattr(vban, "bus")
assert hasattr(vban, "command")
assert len(tests.strip) == 3
assert len(tests.bus) == 2
assert len(vban.strip) == 3
assert len(vban.bus) == 2
@pytest.mark.skipif(
data.name != "banana",
reason="Skip test if kind is not basic",
)
def test_it_tests_remote_attrs_for_banana(self):
assert hasattr(tests, "strip")
assert hasattr(tests, "bus")
assert hasattr(tests, "command")
assert hasattr(vban, "strip")
assert hasattr(vban, "bus")
assert hasattr(vban, "command")
assert len(tests.strip) == 5
assert len(tests.bus) == 5
assert len(vban.strip) == 5
assert len(vban.bus) == 5
@pytest.mark.skipif(
data.name != "potato",
reason="Skip test if kind is not basic",
)
def test_it_tests_remote_attrs_for_potato(self):
assert hasattr(tests, "strip")
assert hasattr(tests, "bus")
assert hasattr(tests, "command")
assert hasattr(vban, "strip")
assert hasattr(vban, "bus")
assert hasattr(vban, "command")
assert len(tests.strip) == 8
assert len(tests.bus) == 8
assert len(vban.strip) == 8
assert len(vban.bus) == 8

View File

@ -1,6 +1,6 @@
import pytest
from tests import data, tests
from tests import data, vban
@pytest.mark.parametrize("value", [False, True])
@ -17,8 +17,8 @@ class TestSetAndGetBoolHigher:
],
)
def test_it_sets_and_gets_strip_bool_params(self, index, param, value):
setattr(tests.strip[index], param, value)
assert getattr(tests.strip[index], param) == value
setattr(vban.strip[index], param, value)
assert getattr(vban.strip[index], param) == value
@pytest.mark.skipif(
data.name == "banana",
@ -31,8 +31,8 @@ class TestSetAndGetBoolHigher:
],
)
def test_it_sets_and_gets_strip_bool_params_mc(self, index, param, value):
setattr(tests.strip[index], param, value)
assert getattr(tests.strip[index], param) == value
setattr(vban.strip[index], param, value)
assert getattr(vban.strip[index], param) == value
""" bus tests, physical and virtual """
@ -46,8 +46,8 @@ class TestSetAndGetBoolHigher:
],
)
def test_it_sets_and_gets_bus_bool_params(self, index, param, value):
setattr(tests.bus[index], param, value)
assert getattr(tests.bus[index], param) == value
setattr(vban.bus[index], param, value)
assert getattr(vban.bus[index], param) == value
""" bus modes tests, physical and virtual """
@ -66,8 +66,8 @@ class TestSetAndGetBoolHigher:
# here it only makes sense to set/get bus modes as True
if not value:
value = True
setattr(tests.bus[index].mode, param, value)
assert getattr(tests.bus[index].mode, param) == value
setattr(vban.bus[index].mode, param, value)
assert getattr(vban.bus[index].mode, param) == value
""" command tests """
@ -76,7 +76,7 @@ class TestSetAndGetBoolHigher:
[("lock")],
)
def test_it_sets_command_bool_params(self, param, value):
setattr(tests.command, param, value)
setattr(vban.command, param, value)
class TestSetAndGetIntHigher:
@ -94,8 +94,8 @@ class TestSetAndGetIntHigher:
],
)
def test_it_sets_and_gets_strip_bool_params(self, index, param, value):
setattr(tests.strip[index], param, value)
assert getattr(tests.strip[index], param) == value
setattr(vban.strip[index], param, value)
assert getattr(vban.strip[index], param) == value
class TestSetAndGetFloatHigher:
@ -113,15 +113,15 @@ class TestSetAndGetFloatHigher:
],
)
def test_it_sets_and_gets_strip_float_params(self, index, param, value):
setattr(tests.strip[index], param, value)
assert getattr(tests.strip[index], param) == value
setattr(vban.strip[index], param, value)
assert getattr(vban.strip[index], param) == value
@pytest.mark.parametrize(
"index,value",
[(data.phys_in, 2), (data.phys_in, 2), (data.virt_in, 8), (data.virt_in, 8)],
)
def test_it_gets_prefader_levels_and_compares_length_of_array(self, index, value):
assert len(tests.strip[index].levels.prefader) == value
assert len(vban.strip[index].levels.prefader) == value
@pytest.mark.skipif(
data.name != "potato",
@ -137,8 +137,8 @@ class TestSetAndGetFloatHigher:
],
)
def test_it_sets_and_gets_strip_gainlayer_values(self, index, j, value):
tests.strip[index].gainlayer[j].gain = value
assert tests.strip[index].gainlayer[j].gain == value
vban.strip[index].gainlayer[j].gain = value
assert vban.strip[index].gainlayer[j].gain == value
""" strip tests, virtual """
@ -151,8 +151,8 @@ class TestSetAndGetFloatHigher:
],
)
def test_it_sets_and_gets_strip_eq_params(self, index, param, value):
setattr(tests.strip[index], param, value)
assert getattr(tests.strip[index], param) == value
setattr(vban.strip[index], param, value)
assert getattr(vban.strip[index], param) == value
""" bus tests, physical and virtual """
@ -161,15 +161,15 @@ class TestSetAndGetFloatHigher:
[(data.phys_out, "gain", -3.6), (data.virt_out, "gain", 5.8)],
)
def test_it_sets_and_gets_bus_float_params(self, index, param, value):
setattr(tests.bus[index], param, value)
assert getattr(tests.bus[index], param) == value
setattr(vban.bus[index], param, value)
assert getattr(vban.bus[index], param) == value
@pytest.mark.parametrize(
"index,value",
[(data.phys_out, 8), (data.virt_out, 8)],
)
def test_it_gets_prefader_levels_and_compares_length_of_array(self, index, value):
assert len(tests.bus[index].levels.all) == value
assert len(vban.bus[index].levels.all) == value
@pytest.mark.parametrize("value", ["test0", "test1"])
@ -183,8 +183,8 @@ class TestSetAndGetStringHigher:
[(data.phys_in, "label"), (data.virt_in, "label")],
)
def test_it_sets_and_gets_strip_string_params(self, index, param, value):
setattr(tests.strip[index], param, value)
assert getattr(tests.strip[index], param) == value
setattr(vban.strip[index], param, value)
assert getattr(vban.strip[index], param) == value
""" bus tests, physical and virtual """
@ -193,5 +193,5 @@ class TestSetAndGetStringHigher:
[(data.phys_out, "label"), (data.virt_out, "label")],
)
def test_it_sets_and_gets_bus_string_params(self, index, param, value):
setattr(tests.bus[index], param, value)
assert getattr(tests.bus[index], param) == value
setattr(vban.bus[index], param, value)
assert getattr(vban.bus[index], param) == value

View File

@ -1,9 +1,9 @@
import time
import pytest
from vban_cmd import kinds
from tests import data, tests
from tests import data, vban
from vban_cmd import kinds
class TestPublicPacketLower:
@ -12,7 +12,7 @@ class TestPublicPacketLower:
"""Tests for a valid rt data packet"""
def test_it_gets_an_rt_data_packet(self):
assert tests.public_packet.voicemeetertype in (
assert vban.public_packet.voicemeetertype in (
kind.name for kind in kinds.kinds_all
)
@ -35,7 +35,7 @@ class TestSetRT:
],
)
def test_it_sends_a_text_request(self, kls, index, param, value):
tests._set_rt(f"{kls}[{index}]", param, value)
vban._set_rt(f"{kls}[{index}]", param, value)
time.sleep(0.02)
target = getattr(tests, kls)[index]
target = getattr(vban, kls)[index]
assert getattr(target, param) == bool(value)