test against localhost

run tests through formatter

remove sel test from bus bool params
This commit is contained in:
Onyx and Iris 2025-01-17 15:01:40 +00:00
parent af68c423a6
commit bc2cd3e7a5
8 changed files with 109 additions and 108 deletions

View File

@ -13,8 +13,8 @@ KIND_ID = os.environ.get(
) )
opts = { opts = {
'ip': 'ws.local', 'ip': 'localhost',
'streamname': 'workstation', 'streamname': 'onyx',
'port': 6980, 'port': 6980,
'bps': 0, 'bps': 0,
} }

View File

@ -1,7 +1,7 @@
def pytest_addoption(parser): def pytest_addoption(parser):
parser.addoption( parser.addoption(
"--run-slow", '--run-slow',
action="store_true", action='store_true',
default=False, default=False,
help="Run slow tests", help='Run slow tests',
) )

View File

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

View File

@ -3,7 +3,7 @@ import re
import pytest import pytest
import vban_cmd import vban_cmd
from tests import data, vban from tests import vban
class TestErrors: class TestErrors:
@ -12,26 +12,26 @@ class TestErrors:
def test_it_tests_an_unknown_kind(self): def test_it_tests_an_unknown_kind(self):
with pytest.raises( with pytest.raises(
vban_cmd.error.VBANCMDError, vban_cmd.error.VBANCMDError,
match=f"Unknown Voicemeeter kind 'unknown_kind'", match="Unknown Voicemeeter kind 'unknown_kind'",
): ):
vban_cmd.api("unknown_kind") vban_cmd.api('unknown_kind')
def test_it_tests_an_unknown_config_name(self): def test_it_tests_an_unknown_config_name(self):
EXPECTED_MSG = "\n".join( EXPECTED_MSG = '\n'.join(
( (
f"No config with name 'unknown' is loaded into memory", "No config with name 'unknown' is loaded into memory",
f"Known configs: {list(vban.configs.keys())}", f'Known configs: {list(vban.configs.keys())}',
) )
) )
with pytest.raises(vban_cmd.error.VBANCMDError, match=re.escape(EXPECTED_MSG)): with pytest.raises(vban_cmd.error.VBANCMDError, match=re.escape(EXPECTED_MSG)):
vban.apply_config("unknown") vban.apply_config('unknown')
def test_it_tests_an_invalid_config_key(self): def test_it_tests_an_invalid_config_key(self):
CONFIG = { CONFIG = {
"strip-0": {"A1": True, "B1": True, "gain": -6.0}, 'strip-0': {'A1': True, 'B1': True, 'gain': -6.0},
"bus-0": {"mute": True, "eq": {"on": True}}, 'bus-0': {'mute': True, 'eq': {'on': True}},
"unknown-0": {"state": True}, 'unknown-0': {'state': True},
"vban-out-1": {"name": "streamname"}, 'vban-out-1': {'name': 'streamname'},
} }
with pytest.raises(ValueError, match="invalid config key 'unknown-0'"): with pytest.raises(ValueError, match="invalid config key 'unknown-0'"):
vban.apply(CONFIG) vban.apply(CONFIG)

View File

@ -7,15 +7,15 @@ class TestRemoteFactories:
__test__ = True __test__ = True
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "basic", data.name != 'basic',
reason="Skip test if kind is not basic", reason='Skip test if kind is not basic',
) )
def test_it_tests_remote_attrs_for_basic(self): def test_it_tests_remote_attrs_for_basic(self):
assert hasattr(vban, "strip") assert hasattr(vban, 'strip')
assert hasattr(vban, "bus") assert hasattr(vban, 'bus')
assert hasattr(vban, "command") assert hasattr(vban, 'command')
assert hasattr(vban, "button") assert hasattr(vban, 'button')
assert hasattr(vban, "vban") assert hasattr(vban, 'vban')
assert len(vban.strip) == 3 assert len(vban.strip) == 3
assert len(vban.bus) == 2 assert len(vban.bus) == 2
@ -23,15 +23,15 @@ class TestRemoteFactories:
assert len(vban.vban.instream) == 6 and len(vban.vban.outstream) == 5 assert len(vban.vban.instream) == 6 and len(vban.vban.outstream) == 5
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "banana", data.name != 'banana',
reason="Skip test if kind is not basic", reason='Skip test if kind is not basic',
) )
def test_it_tests_remote_attrs_for_banana(self): def test_it_tests_remote_attrs_for_banana(self):
assert hasattr(vban, "strip") assert hasattr(vban, 'strip')
assert hasattr(vban, "bus") assert hasattr(vban, 'bus')
assert hasattr(vban, "command") assert hasattr(vban, 'command')
assert hasattr(vban, "button") assert hasattr(vban, 'button')
assert hasattr(vban, "vban") assert hasattr(vban, 'vban')
assert len(vban.strip) == 5 assert len(vban.strip) == 5
assert len(vban.bus) == 5 assert len(vban.bus) == 5
@ -39,15 +39,15 @@ class TestRemoteFactories:
assert len(vban.vban.instream) == 10 and len(vban.vban.outstream) == 9 assert len(vban.vban.instream) == 10 and len(vban.vban.outstream) == 9
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "potato", data.name != 'potato',
reason="Skip test if kind is not basic", reason='Skip test if kind is not basic',
) )
def test_it_tests_remote_attrs_for_potato(self): def test_it_tests_remote_attrs_for_potato(self):
assert hasattr(vban, "strip") assert hasattr(vban, 'strip')
assert hasattr(vban, "bus") assert hasattr(vban, 'bus')
assert hasattr(vban, "command") assert hasattr(vban, 'command')
assert hasattr(vban, "button") assert hasattr(vban, 'button')
assert hasattr(vban, "vban") assert hasattr(vban, 'vban')
assert len(vban.strip) == 8 assert len(vban.strip) == 8
assert len(vban.bus) == 8 assert len(vban.bus) == 8

View File

@ -3,17 +3,17 @@ import pytest
from tests import data, vban from tests import data, vban
@pytest.mark.parametrize("value", [False, True]) @pytest.mark.parametrize('value', [False, True])
class TestSetAndGetBoolHigher: class TestSetAndGetBoolHigher:
__test__ = True __test__ = True
"""strip tests, physical and virtual""" """strip tests, physical and virtual"""
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,param", 'index,param',
[ [
(data.phys_in, "mute"), (data.phys_in, 'mute'),
(data.virt_in, "solo"), (data.virt_in, 'solo'),
], ],
) )
def test_it_sets_and_gets_strip_bool_params(self, index, param, value): def test_it_sets_and_gets_strip_bool_params(self, index, param, value):
@ -21,13 +21,13 @@ class TestSetAndGetBoolHigher:
assert getattr(vban.strip[index], param) == value assert getattr(vban.strip[index], param) == value
@pytest.mark.skipif( @pytest.mark.skipif(
data.name == "banana", data.name == 'banana',
reason="Only test if logged into Basic or Potato version", reason='Only test if logged into Basic or Potato version',
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,param", 'index,param',
[ [
(data.phys_in, "mc"), (data.phys_in, 'mc'),
], ],
) )
def test_it_sets_and_gets_strip_bool_params_mc(self, index, param, value): def test_it_sets_and_gets_strip_bool_params_mc(self, index, param, value):
@ -37,10 +37,9 @@ class TestSetAndGetBoolHigher:
""" bus tests, physical and virtual """ """ bus tests, physical and virtual """
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,param", 'index,param',
[ [
(data.phys_out, "mute"), (data.phys_out, 'mute'),
(data.virt_out, "sel"),
], ],
) )
def test_it_sets_and_gets_bus_bool_params(self, index, param, value): def test_it_sets_and_gets_bus_bool_params(self, index, param, value):
@ -51,17 +50,17 @@ class TestSetAndGetBoolHigher:
""" bus modes tests, physical and virtual """ """ bus modes tests, physical and virtual """
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,param", 'index,param',
[ [
(data.phys_out, "normal"), (data.phys_out, 'normal'),
(data.phys_out, "amix"), (data.phys_out, 'amix'),
(data.phys_out, "rearonly"), (data.phys_out, 'rearonly'),
(data.virt_out, "normal"), (data.virt_out, 'normal'),
(data.virt_out, "upmix41"), (data.virt_out, 'upmix41'),
(data.virt_out, "composite"), (data.virt_out, 'composite'),
], ],
) )
def test_it_sets_and_gets_bus_bool_params(self, index, param, value): def test_it_sets_and_gets_bus_mode_bool_params(self, index, param, value):
# here it only makes sense to set/get bus modes as True # here it only makes sense to set/get bus modes as True
if not value: if not value:
value = True value = True
@ -71,8 +70,8 @@ class TestSetAndGetBoolHigher:
""" command tests """ """ command tests """
@pytest.mark.parametrize( @pytest.mark.parametrize(
"param", 'param',
[("lock")], [('lock')],
) )
def test_it_sets_command_bool_params(self, param, value): def test_it_sets_command_bool_params(self, param, value):
setattr(vban.command, param, value) setattr(vban.command, param, value)
@ -86,10 +85,10 @@ class TestSetAndGetIntHigher:
"""strip tests, physical and virtual""" """strip tests, physical and virtual"""
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,param,value", 'index,param,value',
[ [
(data.virt_in, "k", 0), (data.virt_in, 'k', 0),
(data.virt_in, "k", 4), (data.virt_in, 'k', 4),
], ],
) )
def test_it_sets_and_gets_strip_bool_params(self, index, param, value): def test_it_sets_and_gets_strip_bool_params(self, index, param, value):
@ -103,12 +102,12 @@ class TestSetAndGetFloatHigher:
"""strip tests, physical and virtual""" """strip tests, physical and virtual"""
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,param,value", 'index,param,value',
[ [
(data.phys_in, "gain", -3.6), (data.phys_in, 'gain', -3.6),
(data.phys_in, "gain", 3.6), (data.phys_in, 'gain', 3.6),
(data.virt_in, "gain", -5.8), (data.virt_in, 'gain', -5.8),
(data.virt_in, "gain", 5.8), (data.virt_in, 'gain', 5.8),
], ],
) )
def test_it_sets_and_gets_strip_float_params(self, index, param, value): def test_it_sets_and_gets_strip_float_params(self, index, param, value):
@ -116,18 +115,20 @@ class TestSetAndGetFloatHigher:
assert getattr(vban.strip[index], param) == value assert getattr(vban.strip[index], param) == value
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,value", 'index,value',
[(data.phys_in, 2), (data.phys_in, 2), (data.virt_in, 8), (data.virt_in, 8)], [(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): def test_it_gets_strip_prefader_levels_and_compares_length_of_array(
self, index, value
):
assert len(vban.strip[index].levels.prefader) == value assert len(vban.strip[index].levels.prefader) == value
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "potato", data.name != 'potato',
reason="Only test if logged into Potato version", reason='Only test if logged into Potato version',
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, j, value", 'index, j, value',
[ [
(data.phys_in, 0, -20.7), (data.phys_in, 0, -20.7),
(data.virt_in, 3, -60), (data.virt_in, 3, -60),
@ -142,14 +143,14 @@ class TestSetAndGetFloatHigher:
""" strip tests, physical """ """ strip tests, physical """
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "potato", data.name != 'potato',
reason="Only test if logged into Potato version", reason='Only test if logged into Potato version',
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, param, value", 'index, param, value',
[ [
(data.phys_in, "gainin", -8.6), (data.phys_in, 'gainin', -8.6),
(data.phys_in, "knee", 0.24), (data.phys_in, 'knee', 0.24),
], ],
) )
def test_it_sets_strip_comp_params(self, index, param, value): def test_it_sets_strip_comp_params(self, index, param, value):
@ -158,14 +159,14 @@ class TestSetAndGetFloatHigher:
# we can set but not get this value. Not in RT Packet. # we can set but not get this value. Not in RT Packet.
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "potato", data.name != 'potato',
reason="Only test if logged into Potato version", reason='Only test if logged into Potato version',
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, param, value", 'index, param, value',
[ [
(data.phys_in, "bpsidechain", 120), (data.phys_in, 'bpsidechain', 120),
(data.phys_in, "hold", 3000), (data.phys_in, 'hold', 3000),
], ],
) )
def test_it_sets_and_gets_strip_gate_params(self, index, param, value): def test_it_sets_and_gets_strip_gate_params(self, index, param, value):
@ -176,11 +177,11 @@ class TestSetAndGetFloatHigher:
""" strip tests, virtual """ """ strip tests, virtual """
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, param, value", 'index, param, value',
[ [
(data.virt_in, "treble", -1.6), (data.virt_in, 'treble', -1.6),
(data.virt_in, "mid", 5.8), (data.virt_in, 'mid', 5.8),
(data.virt_in, "bass", -8.1), (data.virt_in, 'bass', -8.1),
], ],
) )
def test_it_sets_and_gets_strip_eq_params(self, index, param, value): def test_it_sets_and_gets_strip_eq_params(self, index, param, value):
@ -190,30 +191,30 @@ class TestSetAndGetFloatHigher:
""" bus tests, physical and virtual """ """ bus tests, physical and virtual """
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, param, value", 'index, param, value',
[(data.phys_out, "gain", -3.6), (data.virt_out, "gain", 5.8)], [(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): def test_it_sets_and_gets_bus_float_params(self, index, param, value):
setattr(vban.bus[index], param, value) setattr(vban.bus[index], param, value)
assert getattr(vban.bus[index], param) == value assert getattr(vban.bus[index], param) == value
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index,value", 'index,value',
[(data.phys_out, 8), (data.virt_out, 8)], [(data.phys_out, 8), (data.virt_out, 8)],
) )
def test_it_gets_prefader_levels_and_compares_length_of_array(self, index, value): def test_it_gets_bus_levels_and_compares_length_of_array(self, index, value):
assert len(vban.bus[index].levels.all) == value assert len(vban.bus[index].levels.all) == value
@pytest.mark.parametrize("value", ["test0", "test1"]) @pytest.mark.parametrize('value', ['test0', 'test1'])
class TestSetAndGetStringHigher: class TestSetAndGetStringHigher:
__test__ = True __test__ = True
"""strip tests, physical and virtual""" """strip tests, physical and virtual"""
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, param", 'index, param',
[(data.phys_in, "label"), (data.virt_in, "label")], [(data.phys_in, 'label'), (data.virt_in, 'label')],
) )
def test_it_sets_and_gets_strip_string_params(self, index, param, value): def test_it_sets_and_gets_strip_string_params(self, index, param, value):
setattr(vban.strip[index], param, value) setattr(vban.strip[index], param, value)
@ -222,8 +223,8 @@ class TestSetAndGetStringHigher:
""" bus tests, physical and virtual """ """ bus tests, physical and virtual """
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index, param", 'index, param',
[(data.phys_out, "label"), (data.virt_out, "label")], [(data.phys_out, 'label'), (data.virt_out, 'label')],
) )
def test_it_sets_and_gets_bus_string_params(self, index, param, value): def test_it_sets_and_gets_bus_string_params(self, index, param, value):
setattr(vban.bus[index], param, value) setattr(vban.bus[index], param, value)

View File

@ -15,20 +15,20 @@ class TestPublicPacketLower:
) )
@pytest.mark.parametrize("value", [0, 1]) @pytest.mark.parametrize('value', [0, 1])
class TestSetRT: class TestSetRT:
__test__ = True __test__ = True
"""Tests set_rt""" """Tests set_rt"""
@pytest.mark.parametrize( @pytest.mark.parametrize(
"kls,index,param", 'kls,index,param',
[ [
("strip", data.phys_in, "mute"), ('strip', data.phys_in, 'mute'),
("bus", data.virt_out, "mono"), ('bus', data.virt_out, 'mono'),
], ],
) )
def test_it_sends_a_text_request(self, kls, index, param, value): def test_it_sends_a_text_request(self, kls, index, param, value):
vban._set_rt(f"{kls}[{index}].{param}", value) vban._set_rt(f'{kls}[{index}].{param}', value)
target = getattr(vban, kls)[index] target = getattr(vban, kls)[index]
assert getattr(target, param) == bool(value) assert getattr(target, param) == bool(value)

View File

@ -78,7 +78,7 @@ class FactoryBase(VbanCmd):
def __init__(self, kind_id: str, **kwargs): def __init__(self, kind_id: str, **kwargs):
defaultkwargs = { defaultkwargs = {
'ip': None, 'ip': 'localhost',
'port': 6980, 'port': 6980,
'streamname': 'Command1', 'streamname': 'Command1',
'bps': 0, 'bps': 0,