initial commit

initial commit
This commit is contained in:
onyx-and-iris
2022-06-16 14:07:12 +01:00
parent 6efd13fe85
commit 11275d9473
29 changed files with 3177 additions and 0 deletions

41
tests/__init__.py Normal file
View File

@@ -0,0 +1,41 @@
import random
import sys
from dataclasses import dataclass
import voicemeeterlib
from voicemeeterlib.kinds import KindId, kinds_all
from voicemeeterlib.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))
vmrs = {kind.name: voicemeeterlib.api(kind.name) for kind in kinds_all}
tests = vmrs[kind_id]
kind = kindmap(kind_id)
@dataclass
class Data:
"""bounds data to map tests to a kind"""
name: str = kind.name
phys_in: int = kind.ins[0] - 1
virt_in: int = kind.ins[0] + kind.ins[1] - 1
phys_out: int = kind.outs[0] - 1
virt_out: int = kind.outs[0] + kind.outs[1] - 1
vban_in: int = kind.vban[0] - 1
vban_out: int = kind.vban[1] - 1
button_lower: int = 0
button_upper: int = 79
data = Data()
def setup_module():
print(f"\nRunning tests for kind [{data.name}]\n", file=sys.stdout)
tests.login()
def teardown_module():
tests.logout()

1
tests/banana.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 103"><title>tests: 103</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">103</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">103</text></g></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

1
tests/basic.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="60" height="20" role="img" aria-label="tests: 99"><title>tests: 99</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="60" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="23" height="20" fill="#4c1"/><rect width="60" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="475" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="130">99</text><text x="475" y="140" transform="scale(.1)" fill="#fff" textLength="130">99</text></g></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

1
tests/potato.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 107"><title>tests: 107</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">107</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">107</text></g></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

298
tests/test_higher.py Normal file
View File

@@ -0,0 +1,298 @@
import pytest
from tests import data, tests
@pytest.mark.parametrize("value", [False, True])
class TestSetAndGetBoolHigher:
__test__ = True
"""strip tests, physical and virtual"""
@pytest.mark.parametrize(
"index,param",
[
(data.phys_in, "mute"),
(data.phys_in, "mono"),
(data.virt_in, "mc"),
(data.virt_in, "mono"),
],
)
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
""" bus tests, physical and virtual """
@pytest.mark.parametrize(
"index,param",
[
(data.phys_out, "eq"),
(data.phys_out, "mute"),
(data.virt_out, "eq_ab"),
(data.virt_out, "sel"),
],
)
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
""" bus modes tests, physical and virtual """
@pytest.mark.parametrize(
"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"),
],
)
def test_it_sets_and_gets_bus_bool_params(self, index, param, value):
setattr(tests.bus[index].mode, param, value)
assert getattr(tests.bus[index].mode, param) == value
""" macrobutton tests """
@pytest.mark.parametrize(
"index,param",
[(data.button_lower, "state"), (data.button_upper, "trigger")],
)
def test_it_sets_and_gets_macrobutton_bool_params(self, index, param, value):
setattr(tests.button[index], param, value)
assert getattr(tests.button[index], param) == value
""" vban instream tests """
@pytest.mark.parametrize(
"index,param",
[(data.vban_in, "on")],
)
def test_it_sets_and_gets_vban_instream_bool_params(self, index, param, value):
setattr(tests.vban.instream[index], param, value)
assert getattr(tests.vban.instream[index], param) == value
""" vban outstream tests """
@pytest.mark.parametrize(
"index,param",
[(data.vban_out, "on")],
)
def test_it_sets_and_gets_vban_outstream_bool_params(self, index, param, value):
setattr(tests.vban.outstream[index], param, value)
assert getattr(tests.vban.outstream[index], param) == value
""" command tests """
@pytest.mark.parametrize(
"param",
[("lock")],
)
def test_it_sets_command_bool_params(self, param, value):
setattr(tests.command, param, value)
""" recorder tests """
@pytest.mark.skipif(
data.name == "basic",
reason="Skip test if kind is basic",
)
@pytest.mark.parametrize(
"param",
[("A1"), ("B2")],
)
def test_it_sets_and_gets_recorder_bool_params(self, param, value):
setattr(tests.recorder, param, value)
assert getattr(tests.recorder, param) == value
@pytest.mark.skipif(
data.name == "basic",
reason="Skip test if kind is basic",
)
@pytest.mark.parametrize(
"param",
[("loop")],
)
def test_it_sets_recorder_bool_params(self, param, value):
setattr(tests.recorder, param, value)
class TestSetAndGetIntHigher:
__test__ = True
"""strip tests, physical and virtual"""
@pytest.mark.parametrize(
"index,param,value",
[
(data.phys_in, "limit", -40),
(data.phys_in, "limit", 12),
(data.virt_in, "k", 0),
(data.virt_in, "k", 4),
],
)
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
""" vban outstream tests """
@pytest.mark.parametrize(
"index,param,value",
[(data.vban_out, "sr", 48000)],
)
def test_it_sets_and_gets_vban_outstream_bool_params(self, index, param, value):
setattr(tests.vban.outstream[index], param, value)
assert getattr(tests.vban.outstream[index], param) == value
class TestSetAndGetFloatHigher:
__test__ = True
"""strip tests, physical and virtual"""
@pytest.mark.parametrize(
"index,param,value",
[
(data.phys_in, "gain", -3.6),
(data.virt_in, "gain", 5.8),
(data.phys_in, "comp", 0.0),
(data.virt_in, "comp", 8.2),
(data.phys_in, "gate", 2.3),
(data.virt_in, "gate", 6.7),
],
)
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
@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
@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_postmute_levels_and_compares_length_of_array(self, index, value):
assert len(tests.strip[index].levels.postmute) == value
@pytest.mark.skipif(
data.name != "potato",
reason="Only test if logged into Potato version",
)
@pytest.mark.parametrize(
"index, j, value",
[
(data.phys_in, 0, -20.7),
(data.virt_in, 3, -60),
(data.virt_in, 4, 3.6),
(data.phys_in, 4, -12.7),
],
)
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
""" strip tests, virtual """
@pytest.mark.parametrize(
"index, param, value",
[
(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):
setattr(tests.strip[index], param, value)
assert getattr(tests.strip[index], param) == value
""" bus tests, physical and virtual """
@pytest.mark.parametrize(
"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(tests.bus[index], param, value)
assert getattr(tests.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
@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")],
)
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
""" bus tests, physical and virtual """
@pytest.mark.parametrize(
"index, param",
[(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
""" vban instream tests """
@pytest.mark.parametrize(
"index, param",
[(data.vban_in, "name")],
)
def test_it_sets_and_gets_vban_instream_string_params(self, index, param, value):
setattr(tests.vban.instream[index], param, value)
assert getattr(tests.vban.instream[index], param) == value
""" vban outstream tests """
@pytest.mark.parametrize(
"index, param",
[(data.vban_out, "name")],
)
def test_it_sets_and_gets_vban_outstream_string_params(self, index, param, value):
setattr(tests.vban.outstream[index], param, value)
assert getattr(tests.vban.outstream[index], param) == value
@pytest.mark.parametrize("value", [False, True])
class TestSetAndGetMacroButtonHigher:
__test__ = True
"""macrobutton tests"""
@pytest.mark.parametrize(
"index, param",
[
(0, "state"),
(39, "stateonly"),
(69, "trigger"),
(22, "stateonly"),
(45, "state"),
(65, "trigger"),
],
)
def test_it_sets_and_gets_macrobutton_params(self, index, param, value):
setattr(tests.button[index], param, value)
assert getattr(tests.button[index], param) == value

78
tests/test_lower.py Normal file
View File

@@ -0,0 +1,78 @@
import pytest
from tests import data, tests
class TestSetAndGetFloatLower:
__test__ = True
"""VBVMR_SetParameterFloat, VBVMR_GetParameterFloat"""
@pytest.mark.parametrize(
"param,value",
[
(f"Strip[{data.phys_in}].Mute", 1),
(f"Bus[{data.virt_out}].Eq.on", 1),
(f"Strip[{data.phys_in}].Mute", 0),
(f"Bus[{data.virt_out}].Eq.on", 0),
],
)
def test_it_sets_and_gets_mute_eq_float_params(self, param, value):
tests.set(param, value)
assert (round(tests.get(param))) == value
@pytest.mark.parametrize(
"param,value",
[
(f"Strip[{data.phys_in}].Comp", 5.3),
(f"Strip[{data.virt_in}].Gain", -37.5),
(f"Bus[{data.virt_out}].Gain", -22.7),
],
)
def test_it_sets_and_gets_comp_gain_float_params(self, param, value):
tests.set(param, value)
assert (round(tests.get(param), 1)) == value
@pytest.mark.parametrize("value", ["test0", "test1"])
class TestSetAndGetStringLower:
__test__ = True
"""VBVMR_SetParameterStringW, VBVMR_GetParameterStringW"""
@pytest.mark.parametrize(
"param",
[(f"Strip[{data.phys_out}].label"), (f"Bus[{data.virt_out}].label")],
)
def test_it_sets_and_gets_string_params(self, param, value):
tests.set(param, value)
assert tests.get(param, string=True) == value
@pytest.mark.parametrize("value", [0, 1])
class TestMacroButtonsLower:
"""VBVMR_MacroButton_SetStatus, VBVMR_MacroButton_GetStatus"""
@pytest.mark.parametrize(
"index, mode",
[(33, 1), (49, 1)],
)
def test_it_sets_and_gets_macrobuttons_state(self, index, mode, value):
tests.set_buttonstatus(index, value, mode)
assert tests.get_buttonstatus(index, mode) == value
@pytest.mark.parametrize(
"index, mode",
[(14, 2), (12, 2)],
)
def test_it_sets_and_gets_macrobuttons_stateonly(self, index, mode, value):
tests.set_buttonstatus(index, value, mode)
assert tests.get_buttonstatus(index, mode) == value
@pytest.mark.parametrize(
"index, mode",
[(50, 3), (65, 3)],
)
def test_it_sets_and_gets_macrobuttons_trigger(self, index, mode, value):
tests.set_buttonstatus(index, value, mode)
assert tests.get_buttonstatus(index, mode) == value