Coverage for tests / unit / cli_utils / command_chainer / test_normalize_args.py: 100%
24 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
1"""Tests for CommandChainer.normalize_args method."""
3from __future__ import annotations
5import click
6from assertpy import assert_that
8from lintro.cli_utils.command_chainer import CommandChainer
11def test_normalize_already_separated(mock_group: click.Group) -> None:
12 """Test normalization of already separated args.
14 Args:
15 mock_group: Mocked Click group fixture.
16 """
17 chainer = CommandChainer(mock_group)
19 result = chainer.normalize_args(["fmt", ",", "chk"])
21 assert_that(result).is_equal_to(["fmt", ",", "chk"])
24def test_normalize_joined_commands(mock_group: click.Group) -> None:
25 """Test normalization of joined command names.
27 Args:
28 mock_group: Mocked Click group fixture.
29 """
30 chainer = CommandChainer(mock_group)
32 result = chainer.normalize_args(["fmt,chk"])
34 assert_that(result).is_equal_to(["fmt", ",", "chk"])
37def test_normalize_preserves_arguments(mock_group: click.Group) -> None:
38 """Test that command arguments are preserved.
40 Args:
41 mock_group: Mocked Click group fixture.
42 """
43 chainer = CommandChainer(mock_group)
45 result = chainer.normalize_args(["fmt", ".", ",", "chk", "."])
47 assert_that(result).is_equal_to(["fmt", ".", ",", "chk", "."])
50def test_normalize_preserves_comma_in_option_value(mock_group: click.Group) -> None:
51 """Test that comma in option values is preserved.
53 Args:
54 mock_group: Mocked Click group fixture.
55 """
56 chainer = CommandChainer(mock_group)
58 result = chainer.normalize_args(["fmt", "--tools", "ruff,bandit"])
60 assert_that(result).is_equal_to(["fmt", "--tools", "ruff,bandit"])
63def test_normalize_multiple_commands(mock_group: click.Group) -> None:
64 """Test normalization of multiple chained commands.
66 Args:
67 mock_group: Mocked Click group fixture.
68 """
69 chainer = CommandChainer(mock_group)
71 result = chainer.normalize_args(["fmt,chk,tst"])
73 assert_that(result).is_equal_to(["fmt", ",", "chk", ",", "tst"])