forked from openSUSE/docbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_worker_option.py
More file actions
27 lines (19 loc) · 972 Bytes
/
test_worker_option.py
File metadata and controls
27 lines (19 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from click.testing import CliRunner
from docbuild.cli.cmd_cli import cli
def test_workers_option_integration():
runner = CliRunner()
# We use a command that exists but we don't care if it fails
# due to the directory permissions seen above.
# We are testing the CLI parsing logic here.
result = runner.invoke(cli, ["-j", "1", "config", "show"])
# If '-j' was invalid, exit code would be 2 (Click usage error)
# Since it's valid, it should proceed to validation logic (exit code 1 or 0)
assert result.exit_code != 2
assert "no such option: -j" not in result.output
def test_workers_option_invalid_value():
runner = CliRunner()
# Test an invalid string that should trigger our Pydantic ValueError
result = runner.invoke(cli, ["-j", "not-a-number", "config", "show"])
# This should trigger our 'handle_validation_error' logic
assert result.exit_code == 1
assert "Invalid max_workers value" in result.output