Coverage for tests / unit / cli_utils / command_chainer / test_should_chain.py: 100%
19 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.should_chain method."""
3from __future__ import annotations
5import click
6from assertpy import assert_that
8from lintro.cli_utils.command_chainer import CommandChainer
11def test_should_chain_with_comma_separator(mock_group: click.Group) -> None:
12 """Test detection of comma separator in args.
14 Args:
15 mock_group: Mocked Click group fixture.
16 """
17 chainer = CommandChainer(mock_group)
19 assert_that(chainer.should_chain(["fmt", ",", "chk"])).is_true()
22def test_should_chain_with_joined_commands(mock_group: click.Group) -> None:
23 """Test detection of joined command names.
25 Args:
26 mock_group: Mocked Click group fixture.
27 """
28 chainer = CommandChainer(mock_group)
30 assert_that(chainer.should_chain(["fmt,chk"])).is_true()
33def test_should_not_chain_single_command(mock_group: click.Group) -> None:
34 """Test that single command does not trigger chaining.
36 Args:
37 mock_group: Mocked Click group fixture.
38 """
39 chainer = CommandChainer(mock_group)
41 assert_that(chainer.should_chain(["fmt", "."])).is_false()
44def test_should_not_chain_comma_in_argument(mock_group: click.Group) -> None:
45 """Test that comma in non-command argument doesn't trigger chaining.
47 Args:
48 mock_group: Mocked Click group fixture.
49 """
50 chainer = CommandChainer(mock_group)
52 assert_that(chainer.should_chain(["fmt", "--tools", "ruff,bandit"])).is_false()
55def test_should_not_chain_empty_args(mock_group: click.Group) -> None:
56 """Test that empty args do not trigger chaining.
58 Args:
59 mock_group: Mocked Click group fixture.
60 """
61 chainer = CommandChainer(mock_group)
63 assert_that(chainer.should_chain([])).is_false()