diff options
author | Joel Challis <git@zvecr.com> | 2021-01-05 00:52:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-05 00:52:31 +0000 |
commit | f03b10b6c1c9a5b0e07f7f78c6060610246b4a7f (patch) | |
tree | 7d9df975a5046b8d22b5f20694715287361f96a4 /lib/python/qmk/tests | |
parent | 810eafad121bda333c53490e2d8a29f3a83d9c19 (diff) | |
download | qmk_firmware-f03b10b6c1c9a5b0e07f7f78c6060610246b4a7f.tar.gz qmk_firmware-f03b10b6c1c9a5b0e07f7f78c6060610246b4a7f.zip |
Migrate python tests away from onekey (#11367)
* Migrate python tests away from onekey
* Add stub files to stop lint complaints
* Make all the pytest keymaps compile
Diffstat (limited to 'lib/python/qmk/tests')
-rw-r--r-- | lib/python/qmk/tests/pytest_export.json (renamed from lib/python/qmk/tests/onekey_export.json) | 2 | ||||
-rw-r--r-- | lib/python/qmk/tests/test_cli_commands.py | 68 | ||||
-rw-r--r-- | lib/python/qmk/tests/test_qmk_keymap.py | 32 | ||||
-rw-r--r-- | lib/python/qmk/tests/test_qmk_path.py | 6 |
4 files changed, 57 insertions, 51 deletions
diff --git a/lib/python/qmk/tests/onekey_export.json b/lib/python/qmk/tests/pytest_export.json index 95f0a980f..5fb0d624f 100644 --- a/lib/python/qmk/tests/onekey_export.json +++ b/lib/python/qmk/tests/pytest_export.json | |||
@@ -1,5 +1,5 @@ | |||
1 | { | 1 | { |
2 | "keyboard":"handwired/onekey/pytest", | 2 | "keyboard":"handwired/pytest/basic", |
3 | "keymap":"pytest_unittest", | 3 | "keymap":"pytest_unittest", |
4 | "layout":"LAYOUT", | 4 | "layout":"LAYOUT", |
5 | "layers":[["KC_A"]] | 5 | "layers":[["KC_A"]] |
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index efd9f6cf6..f889833d0 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py | |||
@@ -38,17 +38,17 @@ def test_cformat(): | |||
38 | 38 | ||
39 | 39 | ||
40 | def test_compile(): | 40 | def test_compile(): |
41 | result = check_subcommand('compile', '-kb', 'handwired/onekey/pytest', '-km', 'default', '-n') | 41 | result = check_subcommand('compile', '-kb', 'handwired/pytest/basic', '-km', 'default', '-n') |
42 | check_returncode(result) | 42 | check_returncode(result) |
43 | 43 | ||
44 | 44 | ||
45 | def test_compile_json(): | 45 | def test_compile_json(): |
46 | result = check_subcommand('compile', '-kb', 'handwired/onekey/pytest', '-km', 'default_json', '-n') | 46 | result = check_subcommand('compile', '-kb', 'handwired/pytest/basic', '-km', 'default_json', '-n') |
47 | check_returncode(result) | 47 | check_returncode(result) |
48 | 48 | ||
49 | 49 | ||
50 | def test_flash(): | 50 | def test_flash(): |
51 | result = check_subcommand('flash', '-kb', 'handwired/onekey/pytest', '-km', 'default', '-n') | 51 | result = check_subcommand('flash', '-kb', 'handwired/pytest/basic', '-km', 'default', '-n') |
52 | check_returncode(result) | 52 | check_returncode(result) |
53 | 53 | ||
54 | 54 | ||
@@ -92,20 +92,26 @@ def test_list_keyboards(): | |||
92 | result = check_subcommand('list-keyboards') | 92 | result = check_subcommand('list-keyboards') |
93 | check_returncode(result) | 93 | check_returncode(result) |
94 | # check to see if a known keyboard is returned | 94 | # check to see if a known keyboard is returned |
95 | # this will fail if handwired/onekey/pytest is removed | 95 | # this will fail if handwired/pytest/basic is removed |
96 | assert 'handwired/onekey/pytest' in result.stdout | 96 | assert 'handwired/pytest/basic' in result.stdout |
97 | 97 | ||
98 | 98 | ||
99 | def test_list_keymaps(): | 99 | def test_list_keymaps(): |
100 | result = check_subcommand('list-keymaps', '-kb', 'handwired/onekey/pytest') | 100 | result = check_subcommand('list-keymaps', '-kb', 'handwired/pytest/basic') |
101 | check_returncode(result) | 101 | check_returncode(result) |
102 | assert 'default' and 'test' in result.stdout | 102 | assert 'default' and 'default_json' in result.stdout |
103 | 103 | ||
104 | 104 | ||
105 | def test_list_keymaps_long(): | 105 | def test_list_keymaps_long(): |
106 | result = check_subcommand('list-keymaps', '--keyboard', 'handwired/onekey/pytest') | 106 | result = check_subcommand('list-keymaps', '--keyboard', 'handwired/pytest/basic') |
107 | check_returncode(result) | 107 | check_returncode(result) |
108 | assert 'default' and 'test' in result.stdout | 108 | assert 'default' and 'default_json' in result.stdout |
109 | |||
110 | |||
111 | def test_list_keymaps_community(): | ||
112 | result = check_subcommand('list-keymaps', '--keyboard', 'handwired/pytest/has_community') | ||
113 | check_returncode(result) | ||
114 | assert 'test' in result.stdout | ||
109 | 115 | ||
110 | 116 | ||
111 | def test_list_keymaps_kb_only(): | 117 | def test_list_keymaps_kb_only(): |
@@ -133,40 +139,40 @@ def test_list_keymaps_no_keyboard_found(): | |||
133 | 139 | ||
134 | 140 | ||
135 | def test_json2c(): | 141 | def test_json2c(): |
136 | result = check_subcommand('json2c', 'keyboards/handwired/onekey/keymaps/default_json/keymap.json') | 142 | result = check_subcommand('json2c', 'keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json') |
137 | check_returncode(result) | 143 | check_returncode(result) |
138 | 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' | 144 | 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' |
139 | 145 | ||
140 | 146 | ||
141 | def test_json2c_stdin(): | 147 | def test_json2c_stdin(): |
142 | result = check_subcommand_stdin('keyboards/handwired/onekey/keymaps/default_json/keymap.json', 'json2c', '-') | 148 | result = check_subcommand_stdin('keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json', 'json2c', '-') |
143 | check_returncode(result) | 149 | check_returncode(result) |
144 | 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' | 150 | 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' |
145 | 151 | ||
146 | 152 | ||
147 | def test_info(): | 153 | def test_info(): |
148 | result = check_subcommand('info', '-kb', 'handwired/onekey/pytest') | 154 | result = check_subcommand('info', '-kb', 'handwired/pytest/basic') |
149 | check_returncode(result) | 155 | check_returncode(result) |
150 | assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout | 156 | assert 'Keyboard Name: handwired/pytest/basic' in result.stdout |
151 | assert 'Processor: STM32F303' in result.stdout | 157 | assert 'Processor: atmega32u4' in result.stdout |
152 | assert 'Layout:' not in result.stdout | 158 | assert 'Layout:' not in result.stdout |
153 | assert 'k0' not in result.stdout | 159 | assert 'k0' not in result.stdout |
154 | 160 | ||
155 | 161 | ||
156 | def test_info_keyboard_render(): | 162 | def test_info_keyboard_render(): |
157 | result = check_subcommand('info', '-kb', 'handwired/onekey/pytest', '-l') | 163 | result = check_subcommand('info', '-kb', 'handwired/pytest/basic', '-l') |
158 | check_returncode(result) | 164 | check_returncode(result) |
159 | assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout | 165 | assert 'Keyboard Name: handwired/pytest/basic' in result.stdout |
160 | assert 'Processor: STM32F303' in result.stdout | 166 | assert 'Processor: atmega32u4' in result.stdout |
161 | assert 'Layouts:' in result.stdout | 167 | assert 'Layouts:' in result.stdout |
162 | assert 'k0' in result.stdout | 168 | assert 'k0' in result.stdout |
163 | 169 | ||
164 | 170 | ||
165 | def test_info_keymap_render(): | 171 | def test_info_keymap_render(): |
166 | result = check_subcommand('info', '-kb', 'handwired/onekey/pytest', '-km', 'default_json') | 172 | result = check_subcommand('info', '-kb', 'handwired/pytest/basic', '-km', 'default_json') |
167 | check_returncode(result) | 173 | check_returncode(result) |
168 | assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout | 174 | assert 'Keyboard Name: handwired/pytest/basic' in result.stdout |
169 | assert 'Processor: STM32F303' in result.stdout | 175 | assert 'Processor: atmega32u4' in result.stdout |
170 | 176 | ||
171 | if is_windows: | 177 | if is_windows: |
172 | assert '|A |' in result.stdout | 178 | assert '|A |' in result.stdout |
@@ -175,10 +181,10 @@ def test_info_keymap_render(): | |||
175 | 181 | ||
176 | 182 | ||
177 | def test_info_matrix_render(): | 183 | def test_info_matrix_render(): |
178 | result = check_subcommand('info', '-kb', 'handwired/onekey/pytest', '-m') | 184 | result = check_subcommand('info', '-kb', 'handwired/pytest/basic', '-m') |
179 | check_returncode(result) | 185 | check_returncode(result) |
180 | assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout | 186 | assert 'Keyboard Name: handwired/pytest/basic' in result.stdout |
181 | assert 'Processor: STM32F303' in result.stdout | 187 | assert 'Processor: atmega32u4' in result.stdout |
182 | assert 'LAYOUT_ortho_1x1' in result.stdout | 188 | assert 'LAYOUT_ortho_1x1' in result.stdout |
183 | 189 | ||
184 | if is_windows: | 190 | if is_windows: |
@@ -190,27 +196,27 @@ def test_info_matrix_render(): | |||
190 | 196 | ||
191 | 197 | ||
192 | def test_c2json(): | 198 | def test_c2json(): |
193 | result = check_subcommand("c2json", "-kb", "handwired/onekey/pytest", "-km", "default", "keyboards/handwired/onekey/keymaps/default/keymap.c") | 199 | result = check_subcommand("c2json", "-kb", "handwired/pytest/has_template", "-km", "default", "keyboards/handwired/pytest/has_template/keymaps/default/keymap.c") |
194 | check_returncode(result) | 200 | check_returncode(result) |
195 | assert result.stdout.strip() == '{"keyboard": "handwired/onekey/pytest", "documentation": "This file is a keymap.json file for handwired/onekey/pytest", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}' | 201 | assert result.stdout.strip() == '{"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}' |
196 | 202 | ||
197 | 203 | ||
198 | def test_c2json_nocpp(): | 204 | def test_c2json_nocpp(): |
199 | result = check_subcommand("c2json", "--no-cpp", "-kb", "handwired/onekey/pytest", "-km", "default", "keyboards/handwired/onekey/keymaps/pytest_nocpp/keymap.c") | 205 | result = check_subcommand("c2json", "--no-cpp", "-kb", "handwired/pytest/has_template", "-km", "default", "keyboards/handwired/pytest/has_template/keymaps/nocpp/keymap.c") |
200 | check_returncode(result) | 206 | check_returncode(result) |
201 | assert result.stdout.strip() == '{"keyboard": "handwired/onekey/pytest", "documentation": "This file is a keymap.json file for handwired/onekey/pytest", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_ENTER"]]}' | 207 | assert result.stdout.strip() == '{"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_ENTER"]]}' |
202 | 208 | ||
203 | 209 | ||
204 | def test_c2json_stdin(): | 210 | def test_c2json_stdin(): |
205 | result = check_subcommand_stdin("keyboards/handwired/onekey/keymaps/default/keymap.c", "c2json", "-kb", "handwired/onekey/pytest", "-km", "default", "-") | 211 | result = check_subcommand_stdin("keyboards/handwired/pytest/has_template/keymaps/default/keymap.c", "c2json", "-kb", "handwired/pytest/has_template", "-km", "default", "-") |
206 | check_returncode(result) | 212 | check_returncode(result) |
207 | assert result.stdout.strip() == '{"keyboard": "handwired/onekey/pytest", "documentation": "This file is a keymap.json file for handwired/onekey/pytest", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}' | 213 | assert result.stdout.strip() == '{"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}' |
208 | 214 | ||
209 | 215 | ||
210 | def test_c2json_nocpp_stdin(): | 216 | def test_c2json_nocpp_stdin(): |
211 | result = check_subcommand_stdin("keyboards/handwired/onekey/keymaps/pytest_nocpp/keymap.c", "c2json", "--no-cpp", "-kb", "handwired/onekey/pytest", "-km", "default", "-") | 217 | result = check_subcommand_stdin("keyboards/handwired/pytest/has_template/keymaps/nocpp/keymap.c", "c2json", "--no-cpp", "-kb", "handwired/pytest/has_template", "-km", "default", "-") |
212 | check_returncode(result) | 218 | check_returncode(result) |
213 | assert result.stdout.strip() == '{"keyboard": "handwired/onekey/pytest", "documentation": "This file is a keymap.json file for handwired/onekey/pytest", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_ENTER"]]}' | 219 | assert result.stdout.strip() == '{"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_ENTER"]]}' |
214 | 220 | ||
215 | 221 | ||
216 | def test_clean(): | 222 | def test_clean(): |
diff --git a/lib/python/qmk/tests/test_qmk_keymap.py b/lib/python/qmk/tests/test_qmk_keymap.py index f1ecf2937..b9e80df67 100644 --- a/lib/python/qmk/tests/test_qmk_keymap.py +++ b/lib/python/qmk/tests/test_qmk_keymap.py | |||
@@ -1,38 +1,38 @@ | |||
1 | import qmk.keymap | 1 | import qmk.keymap |
2 | 2 | ||
3 | 3 | ||
4 | def test_template_c_onekey_proton_c(): | 4 | def test_template_c_pytest_basic(): |
5 | templ = qmk.keymap.template_c('handwired/onekey/proton_c') | 5 | templ = qmk.keymap.template_c('handwired/pytest/basic') |
6 | assert templ == qmk.keymap.DEFAULT_KEYMAP_C | 6 | assert templ == qmk.keymap.DEFAULT_KEYMAP_C |
7 | 7 | ||
8 | 8 | ||
9 | def test_template_json_onekey_proton_c(): | 9 | def test_template_json_pytest_basic(): |
10 | templ = qmk.keymap.template_json('handwired/onekey/proton_c') | 10 | templ = qmk.keymap.template_json('handwired/pytest/basic') |
11 | assert templ == {'keyboard': 'handwired/onekey/proton_c'} | 11 | assert templ == {'keyboard': 'handwired/pytest/basic'} |
12 | 12 | ||
13 | 13 | ||
14 | def test_template_c_onekey_pytest(): | 14 | def test_template_c_pytest_has_template(): |
15 | templ = qmk.keymap.template_c('handwired/onekey/pytest') | 15 | templ = qmk.keymap.template_c('handwired/pytest/has_template') |
16 | assert templ == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {__KEYMAP_GOES_HERE__};\n' | 16 | assert templ == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {__KEYMAP_GOES_HERE__};\n' |
17 | 17 | ||
18 | 18 | ||
19 | def test_template_json_onekey_pytest(): | 19 | def test_template_json_pytest_has_template(): |
20 | templ = qmk.keymap.template_json('handwired/onekey/pytest') | 20 | templ = qmk.keymap.template_json('handwired/pytest/has_template') |
21 | assert templ == {'keyboard': 'handwired/onekey/pytest', "documentation": "This file is a keymap.json file for handwired/onekey/pytest"} | 21 | assert templ == {'keyboard': 'handwired/pytest/has_template', "documentation": "This file is a keymap.json file for handwired/pytest/has_template"} |
22 | 22 | ||
23 | 23 | ||
24 | def test_generate_c_onekey_pytest(): | 24 | def test_generate_c_pytest_has_template(): |
25 | templ = qmk.keymap.generate_c('handwired/onekey/pytest', 'LAYOUT', [['KC_A']]) | 25 | templ = qmk.keymap.generate_c('handwired/pytest/has_template', 'LAYOUT', [['KC_A']]) |
26 | assert templ == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT(KC_A)};\n' | 26 | assert templ == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT(KC_A)};\n' |
27 | 27 | ||
28 | 28 | ||
29 | def test_generate_json_onekey_pytest(): | 29 | def test_generate_json_pytest_has_template(): |
30 | templ = qmk.keymap.generate_json('default', 'handwired/onekey/pytest', 'LAYOUT', [['KC_A']]) | 30 | templ = qmk.keymap.generate_json('default', 'handwired/pytest/has_template', 'LAYOUT', [['KC_A']]) |
31 | assert templ == {"keyboard": "handwired/onekey/pytest", "documentation": "This file is a keymap.json file for handwired/onekey/pytest", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_A"]]} | 31 | assert templ == {"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_A"]]} |
32 | 32 | ||
33 | 33 | ||
34 | def test_parse_keymap_c(): | 34 | def test_parse_keymap_c(): |
35 | parsed_keymap_c = qmk.keymap.parse_keymap_c('keyboards/handwired/onekey/keymaps/default/keymap.c') | 35 | parsed_keymap_c = qmk.keymap.parse_keymap_c('keyboards/handwired/pytest/basic/keymaps/default/keymap.c') |
36 | assert parsed_keymap_c == {'layers': [{'name': '0', 'layout': 'LAYOUT_ortho_1x1', 'keycodes': ['KC_A']}]} | 36 | assert parsed_keymap_c == {'layers': [{'name': '0', 'layout': 'LAYOUT_ortho_1x1', 'keycodes': ['KC_A']}]} |
37 | 37 | ||
38 | 38 | ||
diff --git a/lib/python/qmk/tests/test_qmk_path.py b/lib/python/qmk/tests/test_qmk_path.py index 74db7b3e2..4b5132f13 100644 --- a/lib/python/qmk/tests/test_qmk_path.py +++ b/lib/python/qmk/tests/test_qmk_path.py | |||
@@ -4,9 +4,9 @@ from pathlib import Path | |||
4 | import qmk.path | 4 | import qmk.path |
5 | 5 | ||
6 | 6 | ||
7 | def test_keymap_onekey_pytest(): | 7 | def test_keymap_pytest_basic(): |
8 | path = qmk.path.keymap('handwired/onekey/pytest') | 8 | path = qmk.path.keymap('handwired/pytest/basic') |
9 | assert path.samefile('keyboards/handwired/onekey/keymaps') | 9 | assert path.samefile('keyboards/handwired/pytest/basic/keymaps') |
10 | 10 | ||
11 | 11 | ||
12 | def test_normpath(): | 12 | def test_normpath(): |