Skip to content

Commit

Permalink
Remove handwired/pytest/has_template (qmk#24232)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored Aug 3, 2024
1 parent 807ba71 commit 9f387f5
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 78 deletions.

This file was deleted.

This file was deleted.

23 changes: 0 additions & 23 deletions keyboards/handwired/pytest/has_template/keymaps/nocpp/keymap.c

This file was deleted.

Empty file.
Empty file.
2 changes: 0 additions & 2 deletions keyboards/handwired/pytest/has_template/templates/keymap.c

This file was deleted.

3 changes: 0 additions & 3 deletions keyboards/handwired/pytest/has_template/templates/keymap.json

This file was deleted.

78 changes: 58 additions & 20 deletions lib/python/qmk/tests/test_cli_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,34 @@ def test_list_keymaps_no_keyboard_found():


def test_json2c():
result = check_subcommand('json2c', 'keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json')
result = check_subcommand('json2c', 'keyboards/handwired/pytest/basic/keymaps/default_json/keymap.json')
check_returncode(result)
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\n'
assert result.stdout == """#include QMK_KEYBOARD_H
#if __has_include("keymap.h")
# include "keymap.h"
#endif
/* THIS FILE WAS GENERATED!
*
* This file was generated by qmk json2c. You may or may not want to
* edit it directly.
*/
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
\t[0] = LAYOUT_ortho_1x1(KC_A)
};
#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
};
#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
"""


def test_json2c_macros():
Expand All @@ -156,9 +181,34 @@ def test_json2c_macros():


def test_json2c_stdin():
result = check_subcommand_stdin('keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json', 'json2c', '-')
result = check_subcommand_stdin('keyboards/handwired/pytest/basic/keymaps/default_json/keymap.json', 'json2c', '-')
check_returncode(result)
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\n'
assert result.stdout == """#include QMK_KEYBOARD_H
#if __has_include("keymap.h")
# include "keymap.h"
#endif
/* THIS FILE WAS GENERATED!
*
* This file was generated by qmk json2c. You may or may not want to
* edit it directly.
*/
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
\t[0] = LAYOUT_ortho_1x1(KC_A)
};
#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
};
#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
"""


def test_json2c_wrong_json():
Expand Down Expand Up @@ -223,27 +273,15 @@ def test_info_matrix_render():


def test_c2json():
result = check_subcommand("c2json", "-kb", "handwired/pytest/has_template", "-km", "default", "keyboards/handwired/pytest/has_template/keymaps/default/keymap.c")
result = check_subcommand("c2json", "-kb", "handwired/pytest/basic", "-km", "default", "keyboards/handwired/pytest/basic/keymaps/default/keymap.c")
check_returncode(result)
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"]]}'


def test_c2json_nocpp():
result = check_subcommand("c2json", "--no-cpp", "-kb", "handwired/pytest/has_template", "-km", "default", "keyboards/handwired/pytest/has_template/keymaps/nocpp/keymap.c")
check_returncode(result)
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"]]}'
assert result.stdout.strip() == '{"keyboard": "handwired/pytest/basic", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}'


def test_c2json_stdin():
result = check_subcommand_stdin("keyboards/handwired/pytest/has_template/keymaps/default/keymap.c", "c2json", "-kb", "handwired/pytest/has_template", "-km", "default", "-")
check_returncode(result)
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"]]}'


def test_c2json_nocpp_stdin():
result = check_subcommand_stdin("keyboards/handwired/pytest/has_template/keymaps/nocpp/keymap.c", "c2json", "--no-cpp", "-kb", "handwired/pytest/has_template", "-km", "default", "-")
result = check_subcommand_stdin("keyboards/handwired/pytest/basic/keymaps/default/keymap.c", "c2json", "-kb", "handwired/pytest/basic", "-km", "default", "-")
check_returncode(result)
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"]]}'
assert result.stdout.strip() == '{"keyboard": "handwired/pytest/basic", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}'


def test_clean():
Expand Down
45 changes: 29 additions & 16 deletions lib/python/qmk/tests/test_qmk_keymap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,43 @@ def test_template_json_pytest_basic():
assert templ == {'keyboard': 'handwired/pytest/basic'}


def test_template_c_pytest_has_template():
templ = qmk.keymap.template_c('handwired/pytest/has_template')
assert templ == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {__KEYMAP_GOES_HERE__};\n'


def test_template_json_pytest_has_template():
templ = qmk.keymap.template_json('handwired/pytest/has_template')
assert templ == {'keyboard': 'handwired/pytest/has_template', "documentation": "This file is a keymap.json file for handwired/pytest/has_template"}


def test_generate_c_pytest_has_template():
def test_generate_c_pytest_basic():
keymap_json = {
'keyboard': 'handwired/pytest/has_template',
'keyboard': 'handwired/pytest/basic',
'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'
assert templ == """#include QMK_KEYBOARD_H
#if __has_include("keymap.h")
# include "keymap.h"
#endif
/* THIS FILE WAS GENERATED!
*
* This file was generated by qmk json2c. You may or may not want to
* edit it directly.
*/
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
\t[0] = LAYOUT(KC_A)
};
#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
};
#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
"""


def test_generate_json_pytest_has_template():
templ = qmk.keymap.generate_json('default', 'handwired/pytest/has_template', 'LAYOUT', [['KC_A']])
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"]]}
def test_generate_json_pytest_basic():
templ = qmk.keymap.generate_json('default', 'handwired/pytest/basic', 'LAYOUT', [['KC_A']])
assert templ == {"keyboard": "handwired/pytest/basic", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_A"]]}


def test_parse_keymap_c():
Expand Down

0 comments on commit 9f387f5

Please sign in to comment.