From df2f0bb9b23445157325699fc9aa299dc6981f9a Mon Sep 17 00:00:00 2001 From: MattHag <16444067+MattHag@users.noreply.github.com> Date: Sun, 21 Apr 2024 14:32:41 +0200 Subject: [PATCH] diversion: Add unit tests --- tests/logitech_receiver/test_diversion.py | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/logitech_receiver/test_diversion.py diff --git a/tests/logitech_receiver/test_diversion.py b/tests/logitech_receiver/test_diversion.py new file mode 100644 index 0000000000..43c342802e --- /dev/null +++ b/tests/logitech_receiver/test_diversion.py @@ -0,0 +1,31 @@ +from logitech_receiver import diversion +from logitech_receiver.diversion import Key +from logitech_receiver.diversion import KeyPress +from logitech_receiver.diversion import Rule + + +def test_diversion_rule(): + args = [ + { + "Rule": [ # Implement problematic keys for Craft and MX Master + {"Rule": [{"Key": ["Brightness Down", "pressed"]}, {"KeyPress": "XF86_MonBrightnessDown"}]}, + {"Rule": [{"Key": ["Brightness Up", "pressed"]}, {"KeyPress": "XF86_MonBrightnessUp"}]}, + ] + }, + ] + + rule = diversion.Rule(args) + + assert len(rule.components) == 1 + root_rule = rule.components[0] + assert isinstance(root_rule, Rule) + + assert len(root_rule.components) == 2 + for component in root_rule.components: + assert isinstance(component, Rule) + assert len(component.components) == 2 + + key = component.components[0] + assert isinstance(key, Key) + key = component.components[1] + assert isinstance(key, KeyPress)