From 8d862f25cef71ee22d6734ae2cf3f8c2f99146e7 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Wed, 25 Nov 2020 14:06:36 +0100 Subject: keyboard: Move scancodes to yaml file Also add serialization and tests. --- lulua/test_keyboard.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lulua/test_keyboard.py') diff --git a/lulua/test_keyboard.py b/lulua/test_keyboard.py index 7537266..d08f6d1 100644 --- a/lulua/test_keyboard.py +++ b/lulua/test_keyboard.py @@ -20,7 +20,8 @@ import pytest -from .keyboard import defaultKeyboards, Button +from .keyboard import defaultKeyboards, Button, dataDirectory +from .util import YamlLoader def test_defaults (): k = defaultKeyboards['ibmpc105'] @@ -54,6 +55,9 @@ def test_keyboard_getattr (): assert k['CD_ret'] == k.find ('CD_ret') assert k['Cr1'] != k.find ('El1') + with pytest.raises (KeyError): + k['nonexistent_button'] + def test_button_uniqname (): a = Button ('a') assert a.name == 'a' @@ -77,3 +81,15 @@ def test_button_uniqname (): d[b] = 2 assert b in d + # make sure we can only compare to Buttons + assert a != 'hello' + assert a != 1 + assert a != dict () + +def test_serialize (): + """ Make sure serialize (deserialize (x)) of keyboards is identity """ + + rawKeyboards = YamlLoader (dataDirectory, lambda x: x) + name = 'ibmpc105' + assert defaultKeyboards[name].serialize () == rawKeyboards[name] + -- cgit v1.2.3