From b7ca5a8fce0bb8986083b59ba4c4e696646a9981 Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Thu, 7 Nov 2024 21:41:17 +1100 Subject: [PATCH 1/3] Update test to work when knob ID and button ID are the same --- .../models/_tests/test_binds.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/midi_app_controller/models/_tests/test_binds.py b/midi_app_controller/models/_tests/test_binds.py index 0846a2c..4afd8a0 100644 --- a/midi_app_controller/models/_tests/test_binds.py +++ b/midi_app_controller/models/_tests/test_binds.py @@ -59,6 +59,19 @@ def test_valid_binds(binds_data): }, ], ), + ], +) +def test_binds_duplicate_id(binds_data, button_binds, knob_binds): + binds_data["button_binds"] = button_binds + binds_data["knob_binds"] = knob_binds + + with pytest.raises(ValidationError): + Binds(**binds_data) + + +@pytest.mark.parametrize( + "button_binds, knob_binds", + [ ( [{"button_id": 1, "action_id": "Action1"}], [ @@ -71,12 +84,10 @@ def test_valid_binds(binds_data): ), ], ) -def test_binds_duplicate_id(binds_data, button_binds, knob_binds): +def test_allow_knob_button_collision(binds_data, button_binds, knob_binds): binds_data["button_binds"] = button_binds binds_data["knob_binds"] = knob_binds - - with pytest.raises(ValidationError): - Binds(**binds_data) + Binds(**binds_data) @pytest.mark.parametrize("id", [-1, 128]) From ae7e92aebe940e209e58c78284f6cf26002924d1 Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Thu, 7 Nov 2024 21:45:18 +1100 Subject: [PATCH 2/3] Check buttons and knobs separately for duplicates --- midi_app_controller/models/binds.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/midi_app_controller/models/binds.py b/midi_app_controller/models/binds.py index 8489932..69a18ff 100644 --- a/midi_app_controller/models/binds.py +++ b/midi_app_controller/models/binds.py @@ -69,8 +69,14 @@ def check_duplicate_ids(cls, values): button_ids = [bind.button_id for bind in values.button_binds] knob_ids = [bind.knob_id for bind in values.knob_binds] - duplicate = find_duplicate(button_ids + knob_ids) - if duplicate is not None: - raise ValueError(f"id={duplicate} was bound to multiple actions") + duplicate_buttons = find_duplicate(button_ids) + if duplicate_buttons is not None: + raise ValueError( + f"button id={duplicate_buttons} was bound to multiple actions" + ) + + duplicate_knobs = find_duplicate(knob_ids) + if duplicate_knobs is not None: + raise ValueError(f"knob id={duplicate_knobs} was bound to multiple actions") return values From 3979801d0a0bf2d0ce9ed2ae579660e9b676e692 Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Fri, 8 Nov 2024 00:33:16 +1100 Subject: [PATCH 3/3] Pin flexparser!=0.4.0 in test deps --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9f81fab..e8871ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,8 @@ midi-app-controller = "midi_app_controller:napari.yaml" testing = [ "pytest>=8.2.0", "pytest-cov>=5.0.0", - "pytest-qt>=4.0.2" + "pytest-qt>=4.0.2", + "flexparser!=0.4.0" # see https://napari.zulipchat.com/#narrow/channel/212875-general/topic/broken.20pint.2Fflexparser/near/481110284 ] dev = [ "midi-app-controller[testing]",