Coverage for tests/unit_tests/commands/test_apio_drivers.py: 60%
45 statements
« prev ^ index » next coverage.py v7.16.1, created at 2026-09-23 03:53 +0000
« prev ^ index » next coverage.py v7.16.1, created at 2026-09-23 03:53 +0000
1"""Test for the "apio drivers" command."""
3import pytest
4from tests.conftest import ApioRunner
5from apio.utils import apio_platforms
6from apio.commands.apio import apio_top_cli as apio
8# TODO: add a test for ubuntu
9# TODO: add a (dummy) test for windows
12def test_drivers_darwin_only(apio_runner: ApioRunner):
13 """Tests the 'apio drivers' commands on darwin platform."""
14 # -- Skip this test if not running on a darwin platform
15 if not apio_platforms.get_apio_platform().is_darwin: 15 ↛ 18line 15 didn't jump to line 18 because the condition on line 15 was always true
16 pytest.skip("Darwin only")
18 with apio_runner.in_sandbox() as sb:
20 # -- Run 'apio drivers install ftdi'
21 result = sb.invoke_apio_cmd(apio, ["drivers", "install", "ftdi"])
22 sb.assert_result_ok(result)
23 assert (
24 "No driver installation is required on this platform"
25 in result.output
26 )
28 # -- Run 'apio drivers uninstall ftdi'
29 result = sb.invoke_apio_cmd(apio, ["drivers", "uninstall", "ftdi"])
30 sb.assert_result_ok(result)
31 assert (
32 "No driver installation is required on this platform"
33 in result.output
34 )
36 # -- Run 'apio drivers install serial'
37 result = sb.invoke_apio_cmd(apio, ["drivers", "install", "serial"])
38 sb.assert_result_ok(result)
39 assert (
40 "No driver installation is required on this platform"
41 in result.output
42 )
44 # -- Run 'apio drivers uninstall serial'
45 result = sb.invoke_apio_cmd(apio, ["drivers", "uninstall", "serial"])
46 sb.assert_result_ok(result)
47 assert (
48 "No driver installation is required on this platform"
49 in result.output
50 )
53def test_drivers_github_linux_only(apio_runner: ApioRunner):
54 """Tests the 'apio drivers' commands on linux platform."""
56 # -- Skip this test if not running on a linux platform
57 if not apio_platforms.get_apio_platform().is_linux: 57 ↛ 58line 57 didn't jump to line 58 because the condition on line 57 was never true
58 pytest.skip("Linux only")
60 # -- Skip this test if not running on a github workflow. We need
61 # -- the github password-less sudo for this test to succeed.
62 if not apio_runner.is_on_github_workflow(): 62 ↛ 63line 62 didn't jump to line 63 because the condition on line 62 was never true
63 pytest.skip("Github workflow only test")
65 with apio_runner.in_sandbox() as sb:
67 # -- Run 'apio drivers install ftdi'
68 result = sb.invoke_apio_cmd(apio, ["drivers", "install", "ftdi"])
69 sb.assert_result_ok(result)
70 print(result.output)
71 assert "FTDI drivers installed" in result.output
73 # -- Run 'apio drivers uninstall ftdi'
74 result = sb.invoke_apio_cmd(apio, ["drivers", "uninstall", "ftdi"])
75 sb.assert_result_ok(result)
76 print(result.output)
77 assert "FTDI drivers uninstalled" in result.output
79 # -- Run 'apio drivers install serial'
80 result = sb.invoke_apio_cmd(apio, ["drivers", "install", "serial"])
81 sb.assert_result_ok(result)
82 assert "Serial drivers installed" in result.output
84 # -- Run 'apio drivers uninstall serial'
85 result = sb.invoke_apio_cmd(apio, ["drivers", "uninstall", "serial"])
86 sb.assert_result_ok(result)
87 assert "Serial drivers uninstalled" in result.output
90def test_drivers_windows_only(apio_runner: ApioRunner):
91 """Tests the 'apio drivers' commands on a windows platform."""
93 # -- Skip this test if not running on a windows platform
94 if not apio_platforms.get_apio_platform().is_windows: 94 ↛ 97line 94 didn't jump to line 97 because the condition on line 94 was always true
95 pytest.skip("Windows only")
97 with apio_runner.in_sandbox():
99 # TODO: Find a creative way to test 'something' here. Maybe using
100 # a 'dry-run' option that will skip dispatching zadig and the
101 # serial installer and will just print the instructions to the
102 # user.
103 pass