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/test_cli_commands.py | |
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/test_cli_commands.py')
-rw-r--r-- | lib/python/qmk/tests/test_cli_commands.py | 68 |
1 files changed, 37 insertions, 31 deletions
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(): |