diff options
| author | Sergey Vlasov <sigprof@gmail.com> | 2024-09-13 23:52:31 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-14 06:52:31 +1000 |
| commit | 0b3ece1189b11e36790c99a1a80f75413b826bb4 (patch) | |
| tree | 464b4e70e0368ccc7e5c7331f38b8f0f2c9a23ec /lib/python/qmk/tests/test_cli_commands.py | |
| parent | ae4ab5ed31360cbb327436ae7e76d1d0cef59449 (diff) | |
`qmk find`: Fix handling of keys with dots in filter functions (#24393)
Diffstat (limited to 'lib/python/qmk/tests/test_cli_commands.py')
| -rw-r--r-- | lib/python/qmk/tests/test_cli_commands.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index 4c322e0c9d..f18bd12f82 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py | |||
| @@ -347,3 +347,68 @@ def test_format_json_keymap_auto(): | |||
| 347 | result = check_subcommand('format-json', '--format', 'auto', 'lib/python/qmk/tests/minimal_keymap.json') | 347 | result = check_subcommand('format-json', '--format', 'auto', 'lib/python/qmk/tests/minimal_keymap.json') |
| 348 | check_returncode(result) | 348 | check_returncode(result) |
| 349 | assert result.stdout == '{\n "keyboard": "handwired/pytest/basic",\n "keymap": "test",\n "layers": [\n ["KC_A"]\n ],\n "layout": "LAYOUT_ortho_1x1",\n "version": 1\n}\n' | 349 | assert result.stdout == '{\n "keyboard": "handwired/pytest/basic",\n "keymap": "test",\n "layers": [\n ["KC_A"]\n ],\n "layout": "LAYOUT_ortho_1x1",\n "version": 1\n}\n' |
| 350 | |||
| 351 | |||
| 352 | def test_find_exists(): | ||
| 353 | result = check_subcommand('find', '-f', 'exists(rgb_matrix.split_count)', '-p', 'rgb_matrix.split_count') | ||
| 354 | check_returncode(result) | ||
| 355 | values = [s for s in result.stdout.splitlines() if 'rgb_matrix.split_count=' in s] | ||
| 356 | assert len(values) > 0 | ||
| 357 | for s in values: | ||
| 358 | assert '=None' not in s | ||
| 359 | assert '=[' in s | ||
| 360 | |||
| 361 | |||
| 362 | def test_find_absent(): | ||
| 363 | result = check_subcommand('find', '-f', 'absent(rgb_matrix.split_count)', '-p', 'rgb_matrix.split_count') | ||
| 364 | check_returncode(result) | ||
| 365 | values = [s for s in result.stdout.splitlines() if 'rgb_matrix.split_count=' in s] | ||
| 366 | assert len(values) > 0 | ||
| 367 | for s in values: | ||
| 368 | assert '=None' in s | ||
| 369 | assert '=[' not in s | ||
| 370 | |||
| 371 | |||
| 372 | def test_find_length(): | ||
| 373 | result = check_subcommand('find', '-f', 'length(matrix_pins.cols, 6)', '-p', 'matrix_pins.cols') | ||
| 374 | check_returncode(result) | ||
| 375 | values = [s for s in result.stdout.splitlines() if 'matrix_pins.cols=' in s] | ||
| 376 | assert len(values) > 0 | ||
| 377 | for s in values: | ||
| 378 | assert s.count(',') == 5 | ||
| 379 | |||
| 380 | |||
| 381 | def test_find_contains(): | ||
| 382 | result = check_subcommand('find', '-f', 'contains(matrix_pins.cols, B1)', '-p', 'matrix_pins.cols') | ||
| 383 | check_returncode(result) | ||
| 384 | values = [s for s in result.stdout.splitlines() if 'matrix_pins.cols=' in s] | ||
| 385 | assert len(values) > 0 | ||
| 386 | for s in values: | ||
| 387 | assert "'B1'" in s | ||
| 388 | |||
| 389 | |||
| 390 | def test_find_multiple_conditions(): | ||
| 391 | # this is intended to match at least 'crkbd/rev1' | ||
| 392 | result = check_subcommand( | ||
| 393 | 'find', '-f', 'exists(rgb_matrix.split_count)', '-f', 'contains(matrix_pins.cols, B1)', '-f', 'length(matrix_pins.cols, 6)', '-f', 'absent(eeprom.driver)', '-f', 'ws2812.pin=D3', '-p', 'rgb_matrix.split_count', '-p', 'matrix_pins.cols', '-p', | ||
| 394 | 'eeprom.driver', '-p', 'ws2812.pin' | ||
| 395 | ) | ||
| 396 | check_returncode(result) | ||
| 397 | rgb_matrix_split_count_values = [s for s in result.stdout.splitlines() if 'rgb_matrix.split_count=' in s] | ||
| 398 | assert len(rgb_matrix_split_count_values) > 0 | ||
| 399 | for s in rgb_matrix_split_count_values: | ||
| 400 | assert '=None' not in s | ||
| 401 | assert '=[' in s | ||
| 402 | matrix_pins_cols_values = [s for s in result.stdout.splitlines() if 'matrix_pins.cols=' in s] | ||
| 403 | assert len(matrix_pins_cols_values) > 0 | ||
| 404 | for s in matrix_pins_cols_values: | ||
| 405 | assert s.count(',') == 5 | ||
| 406 | assert "'B1'" in s | ||
| 407 | eeprom_driver_values = [s for s in result.stdout.splitlines() if 'eeprom.driver=' in s] | ||
| 408 | assert len(eeprom_driver_values) > 0 | ||
| 409 | for s in eeprom_driver_values: | ||
| 410 | assert '=None' in s | ||
| 411 | ws2812_pin_values = [s for s in result.stdout.splitlines() if 'ws2812.pin=' in s] | ||
| 412 | assert len(ws2812_pin_values) > 0 | ||
| 413 | for s in ws2812_pin_values: | ||
| 414 | assert '=D3' in s | ||
