Skip to content

Commit 5f46b1b

Browse files
committedMay 13, 2024
tests: add cli unit-tests
1 parent 4ba3df1 commit 5f46b1b

File tree

3 files changed

+35
-28
lines changed

3 files changed

+35
-28
lines changed
 

‎.github/workflows/python-app.yml

+2-28
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,6 @@ jobs:
4343
- name: Test install
4444
run: |
4545
python -m pip install --upgrade pip
46-
python -m pip install -U .
46+
python -m pip install -U '.[test]'
4747
- name: Test show usage
48-
run: |
49-
python -m pymobiledevice3 --help
50-
python -m pymobiledevice3 activation --help
51-
python -m pymobiledevice3 afc --help
52-
python -m pymobiledevice3 amfi --help
53-
python -m pymobiledevice3 apps --help
54-
python -m pymobiledevice3 backup2 --help
55-
python -m pymobiledevice3 bonjour --help
56-
python -m pymobiledevice3 companion --help
57-
python -m pymobiledevice3 crash --help
58-
python -m pymobiledevice3 developer --help
59-
python -m pymobiledevice3 diagnostics --help
60-
python -m pymobiledevice3 lockdown --help
61-
python -m pymobiledevice3 mounter --help
62-
python -m pymobiledevice3 notification --help
63-
python -m pymobiledevice3 pcap --help
64-
python -m pymobiledevice3 power-assertion --help
65-
python -m pymobiledevice3 processes --help
66-
python -m pymobiledevice3 profile --help
67-
python -m pymobiledevice3 provision --help
68-
python -m pymobiledevice3 remote --help
69-
python -m pymobiledevice3 restore --help
70-
python -m pymobiledevice3 springboard --help
71-
python -m pymobiledevice3 syslog --help
72-
python -m pymobiledevice3 usbmux --help
73-
python -m pymobiledevice3 webinspector --help
74-
python -m pymobiledevice3 version --help
48+
run: pytest -m cli

‎pytest.ini

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
filterwarnings =
33
error
44
error::ResourceWarning
5+
markers =
6+
cli: tests for cli interface

‎tests/cli/test_cli.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import shlex
2+
import subprocess
3+
4+
import pytest
5+
from click.testing import CliRunner
6+
7+
from pymobiledevice3 import __main__
8+
9+
pytestmark = [pytest.mark.cli]
10+
11+
12+
def test_cli_main_interface():
13+
runner = CliRunner()
14+
r1 = runner.invoke(__main__.cli, ['--help'])
15+
assert r1.exit_code == 0
16+
17+
r2 = runner.invoke(__main__.cli)
18+
assert r2.exit_code == 0
19+
20+
21+
@pytest.mark.parametrize('group', __main__.CLI_GROUPS.keys())
22+
def test_cli_groups(group):
23+
runner = CliRunner()
24+
group_help_result = runner.invoke(__main__.cli, [group, '--help'])
25+
assert group_help_result.exit_code == 0
26+
27+
28+
@pytest.mark.parametrize('group', __main__.CLI_GROUPS.keys())
29+
def test_cli_from_python_m_flag(group):
30+
cmd = shlex.split(f'python -m pymobiledevice3 {group} --help')
31+
subprocess.run(cmd, check=True)

0 commit comments

Comments
 (0)
Please sign in to comment.