From 727af5501939c69b48ac655b95dae9139b236262 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Fri, 29 Apr 2022 22:01:33 +0100 Subject: [PATCH] start implementing lower tests --- tests/__init__.py | 2 +- tests/test_lower.py | 85 ++++++++++----------------------------------- 2 files changed, 20 insertions(+), 67 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index d9a72e9..febfbd6 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -5,7 +5,7 @@ import random import sys # let's keep things random -kind_id = random.choice(("basic", "banana", "potato")) +kind_id = random.choice(tuple(kind.id for kind in kinds.all)) opts = { "ip": "codey.local", diff --git a/tests/test_lower.py b/tests/test_lower.py index 40e54d9..43d0f39 100644 --- a/tests/test_lower.py +++ b/tests/test_lower.py @@ -1,79 +1,32 @@ import pytest from tests import tests, data +from vbancmd import kinds +import re -class TestSetAndGetFloatLower: - __test__ = False +class TestPublicPacketLower: + __test__ = True - """VBVMR_SetParameterFloat, VBVMR_GetParameterFloat""" + """Tests for a valid rt data packet""" - @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__ = False - - """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 + def test_it_gets_an_rt_data_packet(self): + assert tests.public_packet.voicemeetertype in (kind.id for kind in kinds.all) @pytest.mark.parametrize("value", [0, 1]) -class TestMacroButtonsLower: - __test__ = False +class TestSetRT: + __test__ = True - """VBVMR_MacroButton_SetStatus, VBVMR_MacroButton_GetStatus""" + """Tests set_rt""" @pytest.mark.parametrize( - "index, mode", - [(33, 1), (49, 1)], + "kls,index,param", + [ + ("strip", data.phys_in, "mute"), + ("bus", data.virt_out, "mono"), + ], ) - 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 + def test_it_gets_an_rt_data_packet(self, kls, index, param, value): + tests.set_rt(f"{kls}[{index}]", param, value) + target = getattr(tests, kls)[index] + assert getattr(target, param) == bool(value)