From 6501377070ff20bd061ea85c7ae5517652b6478b Mon Sep 17 00:00:00 2001 From: Erovia Date: Tue, 26 May 2020 17:43:33 +0200 Subject: CLI: fix `json2c` subcommand and add/fix tests (#9206) Co-authored-by: Zach White --- lib/python/qmk/tests/test_cli_commands.py | 6 ++++++ lib/python/qmk/tests/test_qmk_keymap.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/python/qmk/tests') diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index a93587150c..768929de1d 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -84,3 +84,9 @@ def test_list_keymaps_no_keyboard_found(): result = check_subcommand('list-keymaps', '-kb', 'asdfghjkl') assert result.returncode == 0 assert 'does not exist' in result.stdout + + +def test_json2c(): + result = check_subcommand('json2c', 'keyboards/handwired/onekey/keymaps/default_json/keymap.json') + assert result.returncode == 0 + assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT(KC_A)};\n\n' diff --git a/lib/python/qmk/tests/test_qmk_keymap.py b/lib/python/qmk/tests/test_qmk_keymap.py index 2db625600e..d8669e5498 100644 --- a/lib/python/qmk/tests/test_qmk_keymap.py +++ b/lib/python/qmk/tests/test_qmk_keymap.py @@ -8,12 +8,12 @@ def test_template_onekey_proton_c(): def test_template_onekey_pytest(): templ = qmk.keymap.template('handwired/onekey/pytest') - assert templ == 'const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {__KEYMAP_GOES_HERE__};\n' + assert templ == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {__KEYMAP_GOES_HERE__};\n' def test_generate_onekey_pytest(): templ = qmk.keymap.generate('handwired/onekey/pytest', 'LAYOUT', [['KC_A']]) - assert templ == 'const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT(KC_A)};\n' + assert templ == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT(KC_A)};\n' # FIXME(skullydazed): Add a test for qmk.keymap.write that mocks up an FD. -- cgit v1.2.3