From d4dc743a85641dd74c708aa12fb78b91035cc802 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Tue, 1 Feb 2022 20:44:42 -0800 Subject: Fix issues with Python Tests (#16162) * Reformat python due to yapf changes * Fix pytest keymap list test * revert formatting * Use contra, because, well https://www.reddit.com/r/MechanicalKeyboards/comments/8riofq/did_i_kill_my_contra/ --- lib/python/qmk/tests/test_cli_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 2973f81702..54b143c64f 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -113,7 +113,7 @@ def test_list_keymaps_community(): def test_list_keymaps_kb_only(): - result = check_subcommand('list-keymaps', '-kb', 'niu_mini') + result = check_subcommand('list-keymaps', '-kb', 'contra') check_returncode(result) assert 'default' and 'via' in result.stdout -- cgit v1.2.3 From fbfd5312b995a32af690c183cad0dc988f695e89 Mon Sep 17 00:00:00 2001 From: Erovia Date: Mon, 28 Feb 2022 20:02:39 +0000 Subject: CLI: Validate JSON keymap input (#16261) * Fix schema validator It should use the passed schema. * Add required attributes to keymap schema * Rework subcommands to validate the JSON keymaps The 'compile', 'flash' and 'json2c' subcommands were reworked to add JSON keymap validation so error is reported for non-JSON and non-compliant-JSON inputs. * Fix required fields in keymap schema * Add tests * Fix compiling keymaps directly from keymap directory * Schema should not require version for now. --- lib/python/qmk/tests/test_cli_commands.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (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 54b143c64f..55e69175e6 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -156,6 +156,18 @@ def test_json2c_stdin(): assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT_ortho_1x1(KC_A)};\n\n' +def test_json2c_wrong_json(): + result = check_subcommand('json2c', 'keyboards/handwired/pytest/info.json') + check_returncode(result, [1]) + assert 'Invalid JSON keymap' in result.stdout + + +def test_json2c_no_json(): + result = check_subcommand('json2c', 'keyboards/handwired/pytest/pytest.h') + check_returncode(result, [1]) + assert 'Invalid JSON encountered' in result.stdout + + def test_info(): result = check_subcommand('info', '-kb', 'handwired/pytest/basic') check_returncode(result) -- cgit v1.2.3