From b02f3af665286e1557d4b7daeac92acf904fd475 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sat, 1 Jul 2023 19:26:32 +0100 Subject: [PATCH] add recorder, recorder.mode tests --- CHANGELOG.md | 2 +- tests/__init__.py | 52 ++++++++++++++++++++------------ tests/test_higher.py | 70 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b603613..52f8938 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass - [x] -## [2.1.0] - 2023-06-30 +## [2.1.0] - 2023-07-01 ### Added diff --git a/tests/__init__.py b/tests/__init__.py index e109362..19bb563 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -6,36 +6,50 @@ import voicemeeterlib from voicemeeterlib.kinds import KindId 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)) -vm = voicemeeterlib.api(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 - asio_in: int = kind.asio[0] - 1 - asio_out: int = kind.asio[-1] - 1 - insert_lower: int = 0 - insert_higher: int = kind.insert - 1 + name: str + phys_in: int + virt_in: int + phys_out: int + virt_out: int + vban_in: int + vban_out: int + button_lower: int + button_upper: int + asio_in: int + asio_out: int + insert_lower: int + insert_higher: int @property def channels(self): return (2 * self.phys_in) + (8 * self.virt_in) -data = Data() +# let's keep things random +KIND_ID = random.choice(tuple(kind_id.name.lower() for kind_id in KindId)) +vm = voicemeeterlib.api(KIND_ID) +kind = kindmap(KIND_ID) + +data = Data( + name=kind.name, + phys_in=kind.ins[0] - 1, + virt_in=kind.ins[0] + kind.ins[-1] - 1, + phys_out=kind.outs[0] - 1, + virt_out=kind.outs[0] + kind.outs[-1] - 1, + vban_in=kind.vban[0] - 1, + vban_out=kind.vban[-1] - 1, + button_lower=0, + button_upper=79, + asio_in=kind.asio[0] - 1, + asio_out=kind.asio[-1] - 1, + insert_lower=0, + insert_higher=kind.insert - 1, +) def setup_module(): diff --git a/tests/test_higher.py b/tests/test_higher.py index 4f5ad35..2ae60e9 100644 --- a/tests/test_higher.py +++ b/tests/test_higher.py @@ -156,6 +156,7 @@ class TestSetAndGetBoolHigher: [("A1"), ("B2")], ) def test_it_sets_and_gets_recorder_bool_params(self, param, value): + assert hasattr(vm.recorder, param) setattr(vm.recorder, param, value) assert getattr(vm.recorder, param) == value @@ -168,7 +169,56 @@ class TestSetAndGetBoolHigher: [("loop")], ) def test_it_sets_recorder_bool_params(self, param, value): + assert hasattr(vm.recorder, param) setattr(vm.recorder, param, value) + assert getattr(vm.recorder, param) == value + + """ recoder.mode tests """ + + @pytest.mark.skipif( + data.name == "basic", + reason="Skip test if kind is basic", + ) + @pytest.mark.parametrize( + "param", + [("loop"), ("recbus")], + ) + def test_it_sets_recorder_mode_bool_params(self, param, value): + assert hasattr(vm.recorder.mode, param) + setattr(vm.recorder.mode, param, value) + assert getattr(vm.recorder.mode, param) == value + + """ recorder.armstrip """ + + @pytest.mark.skipif( + data.name == "basic", + reason="Skip test if kind is basic", + ) + @pytest.mark.parametrize( + "index", + [ + (data.phys_out), + (data.virt_out), + ], + ) + def test_it_sets_recorder_armstrip_bool_params(self, index, value): + vm.recorder.armstrip[index].set(value) + + """ recorder.armbus """ + + @pytest.mark.skipif( + data.name == "basic", + reason="Skip test if kind is basic", + ) + @pytest.mark.parametrize( + "index", + [ + (data.phys_out), + (data.virt_out), + ], + ) + def test_it_sets_recorder_armbus_bool_params(self, index, value): + vm.recorder.armbus[index].set(True) """ fx tests """ @@ -323,6 +373,26 @@ class TestSetAndGetIntHigher: vm.option.delay[index].set(value) assert vm.option.delay[index].get() == value + """ recorder tests """ + + @pytest.mark.skipif( + data.name == "basic", + reason="Skip test if kind is basic", + ) + @pytest.mark.parametrize( + "param,value", + [ + ("samplerate", 32000), + ("samplerate", 96000), + ("bitresolution", 16), + ("bitresolution", 32), + ], + ) + def test_it_sets_and_gets_recorder_int_params(self, param, value): + assert hasattr(vm.recorder, param) + setattr(vm.recorder, param, value) + assert getattr(vm.recorder, param) == value + class TestSetAndGetFloatHigher: __test__ = True