Coverage for tests/unit_tests/commands/test_shortcuts.py: 100%
20 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-06 10:20 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-06 10:20 +0000
1"""Test command shortcuts."""
3from tests.conftest import ApioRunner
4from apio.commands.apio import apio_top_cli as apio
7def test_command_shortcuts(apio_runner: ApioRunner):
8 """Test the apio root command."""
10 with apio_runner.in_sandbox() as sb:
12 # -- Run 'apio preferences --list'
13 # -- Exact match.
14 result = sb.invoke_apio_cmd(apio, ["preferences", "--list"])
15 sb.assert_result_ok(result)
16 assert "Theme" in result.output
17 assert "light" in result.output
19 # -- Run 'apio pr -xyz'
20 # -- Unique match.
21 result = sb.invoke_apio_cmd(apio, ["pr", "-xyz"])
22 assert result.exit_code != 0
23 assert "Usage: apio preferences" in result.output
25 # -- Run 'apio pr -h'
26 # -- Help text should contain full commands..
27 result = sb.invoke_apio_cmd(apio, ["pr", "-h"])
28 sb.assert_result_ok(result)
29 assert "Usage: apio preferences" in result.output
31 # -- Run 'apio p'
32 # -- Ambiguous match
33 result = sb.invoke_apio_cmd(apio, ["p", "--list"])
34 assert result.exit_code != 0
35 assert "'p' is ambagious: ['packages', 'preferences']" in result.output
37 # -- Run 'apio xyz --list'
38 # -- No match
39 result = sb.invoke_apio_cmd(apio, ["xyz", "--list"])
40 assert result.exit_code != 0
41 assert "No such command 'xyz'" in result.output