Coverage for tests/unit_tests/commands/test_apio_report.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-06 10:20 +0000

1"""Test for the "apio report" command.""" 

2 

3from tests.conftest import ApioRunner 

4from apio.commands.apio import apio_top_cli as apio 

5 

6 

7def test_report_no_apio(apio_runner: ApioRunner): 

8 """Tests the apio report command without an apio.ini file.""" 

9 

10 with apio_runner.in_sandbox() as sb: 

11 

12 # -- Run "apio report" without apio.ini 

13 result = sb.invoke_apio_cmd(apio, ["report"]) 

14 assert result.exit_code != 0, result.output 

15 assert "Error: Missing project file apio.ini" in result.output 

16 

17 

18def test_report_with_env_arg_error(apio_runner: ApioRunner): 

19 """Tests the command with an invalid --env value. This error message 

20 confirms that the --env arg was propagated to the apio.ini loading 

21 logic.""" 

22 

23 with apio_runner.in_sandbox() as sb: 

24 

25 # -- Run "apio report --env no-such-env" 

26 sb.write_apio_ini({"[env:default]": {"top-module": "main"}}) 

27 result = sb.invoke_apio_cmd(apio, ["report", "--env", "no-such-env"]) 

28 assert result.exit_code == 1, result.output 

29 assert ( 

30 "Error: Env 'no-such-env' not found in apio.ini" in result.output 

31 )