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

32 statements  

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

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

2 

3import re 

4from tests.conftest import ApioRunner 

5from apio.commands.apio import apio_top_cli as apio 

6from apio.common.apio_console import cunstyle, cwidth 

7 

8 

9def test_apio_info(apio_runner: ApioRunner): 

10 """Test "apio info" with different parameters""" 

11 

12 with apio_runner.in_sandbox() as sb: 

13 # -- For debugging table column truncation in github testing. 

14 print(f"Apio console width = {cwidth()}") 

15 

16 # -- Execute "apio info" 

17 result = sb.invoke_apio_cmd(apio, ["info"]) 

18 sb.assert_result_ok(result) 

19 assert "platforms" in result.output 

20 

21 # -- Execute "apio info system" 

22 result = sb.invoke_apio_cmd(apio, ["info", "system"]) 

23 sb.assert_result_ok(result) 

24 assert "Platform id" in result.output 

25 # -- The these env options are set by the apio text fixture. We 

26 # -- relax the expression to allow additional env vars that are 

27 # -- injected to the test such as APIO_REMOTE_URL_CONFIG 

28 assert re.search( 

29 r"Active env options \[[^]]*APIO_HOME[^]]*\]", result.output 

30 ) 

31 

32 # -- Execute "apio info platforms" 

33 result = sb.invoke_apio_cmd(apio, ["info", "platforms"]) 

34 sb.assert_result_ok(result) 

35 assert "darwin-arm64" in result.output 

36 assert "Mac OSX" in result.output 

37 assert "ARM 64 bit (Apple Silicon)" in result.output 

38 

39 # -- Execute "apio info colors" 

40 result = sb.invoke_apio_cmd(apio, ["info", "colors"]) 

41 sb.assert_result_ok(result) 

42 assert result.output != cunstyle(result.output) # Colored 

43 assert "ANSI Colors" in result.output 

44 assert "\x1b[31m 1 red \x1b[0m" in result.output 

45 

46 # -- Execute "apio info themes" 

47 result = sb.invoke_apio_cmd(apio, ["info", "themes"]) 

48 # -- It's normal to have 'error' in the output text. 

49 sb.assert_result_ok(result, bad_words=[]) 

50 assert result.output != cunstyle(result.output) # Colored 

51 assert "NO-COLORS" in result.output 

52 assert "apio.cmd_name\x1b[0m" in result.output 

53 

54 # -- Execute "apio info system". It should not emit colors. 

55 result = sb.invoke_apio_cmd(apio, ["info", "system"]) 

56 sb.assert_result_ok(result) 

57 assert result.output != cunstyle(result.output) # Colored