Coverage for tests/unit_tests/commands/test_shortcuts.py: 100%
20 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-07 05:08 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-07 05:08 +0000
1# This file is part of the Apio project
2# (C) 2016-present FPGAwars
3# Project authors:
4# * Jesús Arroyo (Jesus89) (2016-2019)
5# * Juan Gonzalez (obijuan) (2019-2024)
6# * The Apio Team (2024-present)
7# License: GPLv2
9"""Test command shortcuts."""
11from tests.conftest import ApioRunner
12from apio.commands.apio import apio_top_cli as apio
15def test_command_shortcuts(apio_runner: ApioRunner):
16 """Test the apio root command."""
18 with apio_runner.in_sandbox() as sb:
20 # -- Run 'apio preferences --list'
21 # -- Exact match.
22 result = sb.invoke_apio_cmd(apio, ["preferences", "--list"])
23 sb.assert_result_ok(result)
24 assert "Theme" in result.output
25 assert "light" in result.output
27 # -- Run 'apio pr -xyz'
28 # -- Unique match.
29 result = sb.invoke_apio_cmd(apio, ["pr", "-xyz"])
30 assert result.exit_code != 0
31 assert "Usage: apio preferences" in result.output
33 # -- Run 'apio pr -h'
34 # -- Help text should contain full commands..
35 result = sb.invoke_apio_cmd(apio, ["pr", "-h"])
36 sb.assert_result_ok(result)
37 assert "Usage: apio preferences" in result.output
39 # -- Run 'apio p'
40 # -- Ambiguous match
41 result = sb.invoke_apio_cmd(apio, ["p", "--list"])
42 assert result.exit_code != 0
43 assert "'p' is ambagious: ['packages', 'preferences']" in result.output
45 # -- Run 'apio xyz --list'
46 # -- No match
47 result = sb.invoke_apio_cmd(apio, ["xyz", "--list"])
48 assert result.exit_code != 0
49 assert "No such command 'xyz'" in result.output