added support for setting bus mode through dict

bus modes added to all 3 example configs.

config unit tests added
This commit is contained in:
onyx-and-iris 2022-07-16 21:19:10 +01:00
parent 695e3e4999
commit be2b89e3fa
5 changed files with 55 additions and 9 deletions

View File

@ -16,13 +16,13 @@ limit = -15
[strip-3] [strip-3]
label = "VirtStrip0" label = "VirtStrip0"
bass = -3.2 limit = -12
mid = 1.5
treble = 2.1
[strip-4] [strip-4]
label = "VirtStrip1" label = "VirtStrip1"
limit = -12 bass = -3.2
mid = 1.5
treble = 2.1
[bus-0] [bus-0]
label = "PhysBus0" label = "PhysBus0"
@ -35,10 +35,12 @@ mono = true
[bus-2] [bus-2]
label = "PhysBus2" label = "PhysBus2"
eq = true eq = true
mode = "composite"
[bus-3] [bus-3]
label = "VirtBus0" label = "VirtBus0"
eq_ab = true eq_ab = true
mode = "upmix61"
[bus-4] [bus-4]
label = "VirtBus1" label = "VirtBus1"

View File

@ -17,7 +17,9 @@ treble = 2.1
[bus-0] [bus-0]
label = "PhysBus0" label = "PhysBus0"
mute = true mute = true
mode = "composite"
[bus-1] [bus-1]
label = "PhysBus1" label = "VirtBus0"
mono = true mono = true
mode = "amix"

View File

@ -27,9 +27,6 @@ gain = -8.8
label = "VirtStrip0" label = "VirtStrip0"
A3 = true A3 = true
A5 = true A5 = true
bass = -3.2
mid = 1.5
treble = 2.1
[strip-6] [strip-6]
label = "VirtStrip1" label = "VirtStrip1"
@ -38,6 +35,9 @@ k = 3
[strip-7] [strip-7]
label = "VirtStrip2" label = "VirtStrip2"
bass = -3.2
mid = 1.5
treble = 2.1
mc = true mc = true
[bus-0] [bus-0]
@ -54,9 +54,11 @@ eq = true
[bus-3] [bus-3]
label = "PhysBus3" label = "PhysBus3"
mode = "upmix61"
[bus-4] [bus-4]
label = "PhysBus4" label = "PhysBus4"
mode = "composite"
[bus-5] [bus-5]
label = "VirtBus0" label = "VirtBus0"

34
tests/test_configs.py Normal file
View File

@ -0,0 +1,34 @@
import time
import pytest
from tests import data, tests
class TestUserConfigs:
__test__ = True
"""example config tests"""
@classmethod
def setup_class(cls):
tests.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
def test_it_tests_config_bool(self):
assert tests.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"
def test_it_tests_config_bass_med_high(self):
assert tests.strip[data.virt_in].bass == -3.2
assert tests.strip[data.virt_in].mid == 1.5
assert tests.strip[data.virt_in].high == 2.1

View File

@ -27,9 +27,15 @@ class IRemote(metaclass=ABCMeta):
pass pass
def apply(self, data: dict) -> Self: def apply(self, data: dict) -> Self:
def fget(attr, val):
if attr == "mode":
return (getattr(self, attr), val, 1)
return (self, attr, val)
for attr, val in data.items(): for attr, val in data.items():
if hasattr(self, attr): if hasattr(self, attr):
setattr(self, attr, val) target, attr, val = fget(attr, val)
setattr(target, attr, val)
return self return self
def then_wait(self): def then_wait(self):