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 = {
'ip': 'ws.local',
'streamname': 'workstation',
'ip': 'localhost',
'streamname': 'onyx',
'port': 6980,
'bps': 0,
}

View File

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

View File

@ -12,27 +12,27 @@ class TestSetAndGetBoolHigher:
@classmethod
def setup_class(cls):
vban.apply_config("example")
vban.apply_config('example')
time.sleep(0.1)
@pytest.mark.skipif(
"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):
assert "PhysStrip" in vban.strip[data.phys_in].label
assert "VirtStrip" in vban.strip[data.virt_in].label
assert 'PhysStrip' in vban.strip[data.phys_in].label
assert 'VirtStrip' in vban.strip[data.virt_in].label
@pytest.mark.skipif(
"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):
assert vban.strip[0].A1 == True
assert vban.strip[0].A1
@pytest.mark.skipif(
"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):
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 vban_cmd
from tests import data, vban
from tests import vban
class TestErrors:
@ -12,26 +12,26 @@ class TestErrors:
def test_it_tests_an_unknown_kind(self):
with pytest.raises(
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):
EXPECTED_MSG = "\n".join(
EXPECTED_MSG = '\n'.join(
(
f"No config with name 'unknown' is loaded into memory",
f"Known configs: {list(vban.configs.keys())}",
"No config with name 'unknown' is loaded into memory",
f'Known configs: {list(vban.configs.keys())}',
)
)
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):
CONFIG = {
"strip-0": {"A1": True, "B1": True, "gain": -6.0},
"bus-0": {"mute": True, "eq": {"on": True}},
"unknown-0": {"state": True},
"vban-out-1": {"name": "streamname"},
'strip-0': {'A1': True, 'B1': True, 'gain': -6.0},
'bus-0': {'mute': True, 'eq': {'on': True}},
'unknown-0': {'state': True},
'vban-out-1': {'name': 'streamname'},
}
with pytest.raises(ValueError, match="invalid config key 'unknown-0'"):
vban.apply(CONFIG)

View File

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

View File

@ -3,17 +3,17 @@ import pytest
from tests import data, vban
@pytest.mark.parametrize("value", [False, True])
@pytest.mark.parametrize('value', [False, True])
class TestSetAndGetBoolHigher:
__test__ = True
"""strip tests, physical and virtual"""
@pytest.mark.parametrize(
"index,param",
'index,param',
[
(data.phys_in, "mute"),
(data.virt_in, "solo"),
(data.phys_in, 'mute'),
(data.virt_in, 'solo'),
],
)
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
@pytest.mark.skipif(
data.name == "banana",
reason="Only test if logged into Basic or Potato version",
data.name == 'banana',
reason='Only test if logged into Basic or Potato version',
)
@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):
@ -37,10 +37,9 @@ class TestSetAndGetBoolHigher:
""" bus tests, physical and virtual """
@pytest.mark.parametrize(
"index,param",
'index,param',
[
(data.phys_out, "mute"),
(data.virt_out, "sel"),
(data.phys_out, 'mute'),
],
)
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 """
@pytest.mark.parametrize(
"index,param",
'index,param',
[
(data.phys_out, "normal"),
(data.phys_out, "amix"),
(data.phys_out, "rearonly"),
(data.virt_out, "normal"),
(data.virt_out, "upmix41"),
(data.virt_out, "composite"),
(data.phys_out, 'normal'),
(data.phys_out, 'amix'),
(data.phys_out, 'rearonly'),
(data.virt_out, 'normal'),
(data.virt_out, 'upmix41'),
(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
if not value:
value = True
@ -71,8 +70,8 @@ class TestSetAndGetBoolHigher:
""" command tests """
@pytest.mark.parametrize(
"param",
[("lock")],
'param',
[('lock')],
)
def test_it_sets_command_bool_params(self, param, value):
setattr(vban.command, param, value)
@ -86,10 +85,10 @@ class TestSetAndGetIntHigher:
"""strip tests, physical and virtual"""
@pytest.mark.parametrize(
"index,param,value",
'index,param,value',
[
(data.virt_in, "k", 0),
(data.virt_in, "k", 4),
(data.virt_in, 'k', 0),
(data.virt_in, 'k', 4),
],
)
def test_it_sets_and_gets_strip_bool_params(self, index, param, value):
@ -103,12 +102,12 @@ class TestSetAndGetFloatHigher:
"""strip tests, physical and virtual"""
@pytest.mark.parametrize(
"index,param,value",
'index,param,value',
[
(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.phys_in, 'gain', -3.6),
(data.phys_in, 'gain', 3.6),
(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):
@ -116,18 +115,20 @@ class TestSetAndGetFloatHigher:
assert getattr(vban.strip[index], param) == value
@pytest.mark.parametrize(
"index,value",
'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):
def test_it_gets_strip_prefader_levels_and_compares_length_of_array(
self, index, value
):
assert len(vban.strip[index].levels.prefader) == value
@pytest.mark.skipif(
data.name != "potato",
reason="Only test if logged into Potato version",
data.name != 'potato',
reason='Only test if logged into Potato version',
)
@pytest.mark.parametrize(
"index, j, value",
'index, j, value',
[
(data.phys_in, 0, -20.7),
(data.virt_in, 3, -60),
@ -142,14 +143,14 @@ class TestSetAndGetFloatHigher:
""" strip tests, physical """
@pytest.mark.skipif(
data.name != "potato",
reason="Only test if logged into Potato version",
data.name != 'potato',
reason='Only test if logged into Potato version',
)
@pytest.mark.parametrize(
"index, param, value",
'index, param, value',
[
(data.phys_in, "gainin", -8.6),
(data.phys_in, "knee", 0.24),
(data.phys_in, 'gainin', -8.6),
(data.phys_in, 'knee', 0.24),
],
)
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.
@pytest.mark.skipif(
data.name != "potato",
reason="Only test if logged into Potato version",
data.name != 'potato',
reason='Only test if logged into Potato version',
)
@pytest.mark.parametrize(
"index, param, value",
'index, param, value',
[
(data.phys_in, "bpsidechain", 120),
(data.phys_in, "hold", 3000),
(data.phys_in, 'bpsidechain', 120),
(data.phys_in, 'hold', 3000),
],
)
def test_it_sets_and_gets_strip_gate_params(self, index, param, value):
@ -176,11 +177,11 @@ class TestSetAndGetFloatHigher:
""" strip tests, virtual """
@pytest.mark.parametrize(
"index, param, value",
'index, param, value',
[
(data.virt_in, "treble", -1.6),
(data.virt_in, "mid", 5.8),
(data.virt_in, "bass", -8.1),
(data.virt_in, 'treble', -1.6),
(data.virt_in, 'mid', 5.8),
(data.virt_in, 'bass', -8.1),
],
)
def test_it_sets_and_gets_strip_eq_params(self, index, param, value):
@ -190,30 +191,30 @@ class TestSetAndGetFloatHigher:
""" bus tests, physical and virtual """
@pytest.mark.parametrize(
"index, param, value",
[(data.phys_out, "gain", -3.6), (data.virt_out, "gain", 5.8)],
'index, param, value',
[(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(vban.bus[index], param, value)
assert getattr(vban.bus[index], param) == value
@pytest.mark.parametrize(
"index,value",
'index,value',
[(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
@pytest.mark.parametrize("value", ["test0", "test1"])
@pytest.mark.parametrize('value', ['test0', 'test1'])
class TestSetAndGetStringHigher:
__test__ = True
"""strip tests, physical and virtual"""
@pytest.mark.parametrize(
"index, param",
[(data.phys_in, "label"), (data.virt_in, "label")],
'index, param',
[(data.phys_in, 'label'), (data.virt_in, 'label')],
)
def test_it_sets_and_gets_strip_string_params(self, index, param, value):
setattr(vban.strip[index], param, value)
@ -222,8 +223,8 @@ class TestSetAndGetStringHigher:
""" bus tests, physical and virtual """
@pytest.mark.parametrize(
"index, param",
[(data.phys_out, "label"), (data.virt_out, "label")],
'index, param',
[(data.phys_out, 'label'), (data.virt_out, 'label')],
)
def test_it_sets_and_gets_bus_string_params(self, 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:
__test__ = True
"""Tests set_rt"""
@pytest.mark.parametrize(
"kls,index,param",
'kls,index,param',
[
("strip", data.phys_in, "mute"),
("bus", data.virt_out, "mono"),
('strip', data.phys_in, 'mute'),
('bus', data.virt_out, 'mono'),
],
)
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]
assert getattr(target, param) == bool(value)

View File

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