summaryrefslogtreecommitdiff
path: root/lib/python/qmk/tests
diff options
context:
space:
mode:
authorDrashna Jael're <drashna@live.com>2021-12-07 09:27:44 -0800
committerDrashna Jael're <drashna@live.com>2021-12-07 09:27:44 -0800
commit7c18b1c9d3d968ded45e072af3483547c3ec7859 (patch)
treeed7c8a4176033046eacff21228364290b44fcfdb /lib/python/qmk/tests
parent43002bdf77ab0f48af6b04e87edcc37f7cb7b905 (diff)
parent6d0a62920410f50d7f6707960ca1ca0c8fd1d1fa (diff)
Merge commit '6d0a62920410f50d7f6707960ca1ca0c8fd1d1fa' into firmware21
Diffstat (limited to 'lib/python/qmk/tests')
-rw-r--r--lib/python/qmk/tests/minimal_info.json2
-rw-r--r--lib/python/qmk/tests/test_cli_commands.py22
-rw-r--r--lib/python/qmk/tests/test_qmk_keymap.py8
3 files changed, 23 insertions, 9 deletions
diff --git a/lib/python/qmk/tests/minimal_info.json b/lib/python/qmk/tests/minimal_info.json
index 11ef12fefe..3aae4722bf 100644
--- a/lib/python/qmk/tests/minimal_info.json
+++ b/lib/python/qmk/tests/minimal_info.json
@@ -4,7 +4,7 @@
"layouts": {
"LAYOUT": {
"layout": [
- { "label": "KC_A", "x": 0, "y": 0, "matrix": [0, 0] }
+ { "label": "KC_A", "matrix": [0, 0], "x": 0, "y": 0 }
]
}
}
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py
index b39fe5e46d..2973f81702 100644
--- a/lib/python/qmk/tests/test_cli_commands.py
+++ b/lib/python/qmk/tests/test_cli_commands.py
@@ -81,9 +81,9 @@ def test_hello():
def test_format_python():
- result = check_subcommand('format-python', '--dry-run')
+ result = check_subcommand('format-python', '-n', '-a')
check_returncode(result)
- assert 'Python code in `bin/qmk` and `lib/python` is correctly formatted.' in result.stdout
+ assert 'Successfully formatted the python code.' in result.stdout
def test_list_keyboards():
@@ -142,6 +142,14 @@ def test_json2c():
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_macros():
+ result = check_subcommand("json2c", 'keyboards/handwired/pytest/macro/keymaps/default/keymap.json')
+ check_returncode(result)
+ assert 'LAYOUT_ortho_1x1(MACRO_0)' in result.stdout
+ assert 'case MACRO_0:' in result.stdout
+ assert 'SEND_STRING("Hello, World!"SS_TAP(X_ENTER));' in result.stdout
+
+
def test_json2c_stdin():
result = check_subcommand_stdin('keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json', 'json2c', '-')
check_returncode(result)
@@ -151,7 +159,7 @@ def test_json2c_stdin():
def test_info():
result = check_subcommand('info', '-kb', 'handwired/pytest/basic')
check_returncode(result)
- assert 'Keyboard Name: handwired/pytest/basic' in result.stdout
+ assert 'Keyboard Name: pytest' in result.stdout
assert 'Processor: atmega32u4' in result.stdout
assert 'Layout:' not in result.stdout
assert 'k0' not in result.stdout
@@ -160,7 +168,7 @@ def test_info():
def test_info_keyboard_render():
result = check_subcommand('info', '-kb', 'handwired/pytest/basic', '-l')
check_returncode(result)
- assert 'Keyboard Name: handwired/pytest/basic' in result.stdout
+ assert 'Keyboard Name: pytest' in result.stdout
assert 'Processor: atmega32u4' in result.stdout
assert 'Layouts:' in result.stdout
assert 'k0' in result.stdout
@@ -169,7 +177,7 @@ def test_info_keyboard_render():
def test_info_keymap_render():
result = check_subcommand('info', '-kb', 'handwired/pytest/basic', '-km', 'default_json')
check_returncode(result)
- assert 'Keyboard Name: handwired/pytest/basic' in result.stdout
+ assert 'Keyboard Name: pytest' in result.stdout
assert 'Processor: atmega32u4' in result.stdout
if is_windows:
@@ -181,7 +189,7 @@ def test_info_keymap_render():
def test_info_matrix_render():
result = check_subcommand('info', '-kb', 'handwired/pytest/basic', '-m')
check_returncode(result)
- assert 'Keyboard Name: handwired/pytest/basic' in result.stdout
+ assert 'Keyboard Name: pytest' in result.stdout
assert 'Processor: atmega32u4' in result.stdout
assert 'LAYOUT_ortho_1x1' in result.stdout
@@ -242,7 +250,7 @@ def test_generate_config_h():
assert '# define DESCRIPTION handwired/pytest/basic' in result.stdout
assert '# define DIODE_DIRECTION COL2ROW' in result.stdout
assert '# define MANUFACTURER none' in result.stdout
- assert '# define PRODUCT handwired/pytest/basic' in result.stdout
+ assert '# define PRODUCT pytest' in result.stdout
assert '# define PRODUCT_ID 0x6465' in result.stdout
assert '# define VENDOR_ID 0xFEED' in result.stdout
assert '# define MATRIX_COLS 1' in result.stdout
diff --git a/lib/python/qmk/tests/test_qmk_keymap.py b/lib/python/qmk/tests/test_qmk_keymap.py
index b9e80df672..5e2efc1232 100644
--- a/lib/python/qmk/tests/test_qmk_keymap.py
+++ b/lib/python/qmk/tests/test_qmk_keymap.py
@@ -22,7 +22,13 @@ def test_template_json_pytest_has_template():
def test_generate_c_pytest_has_template():
- templ = qmk.keymap.generate_c('handwired/pytest/has_template', 'LAYOUT', [['KC_A']])
+ keymap_json = {
+ 'keyboard': 'handwired/pytest/has_template',
+ 'layout': 'LAYOUT',
+ 'layers': [['KC_A']],
+ 'macros': None,
+ }
+ templ = qmk.keymap.generate_c(keymap_json)
assert templ == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT(KC_A)};\n'