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

1"""Tests for CommandChainer.should_chain method.""" 

2 

3from __future__ import annotations 

4 

5import click 

6from assertpy import assert_that 

7 

8from lintro.cli_utils.command_chainer import CommandChainer 

9 

10 

11def test_should_chain_with_comma_separator(mock_group: click.Group) -> None: 

12 """Test detection of comma separator in args. 

13 

14 Args: 

15 mock_group: Mocked Click group fixture. 

16 """ 

17 chainer = CommandChainer(mock_group) 

18 

19 assert_that(chainer.should_chain(["fmt", ",", "chk"])).is_true() 

20 

21 

22def test_should_chain_with_joined_commands(mock_group: click.Group) -> None: 

23 """Test detection of joined command names. 

24 

25 Args: 

26 mock_group: Mocked Click group fixture. 

27 """ 

28 chainer = CommandChainer(mock_group) 

29 

30 assert_that(chainer.should_chain(["fmt,chk"])).is_true() 

31 

32 

33def test_should_not_chain_single_command(mock_group: click.Group) -> None: 

34 """Test that single command does not trigger chaining. 

35 

36 Args: 

37 mock_group: Mocked Click group fixture. 

38 """ 

39 chainer = CommandChainer(mock_group) 

40 

41 assert_that(chainer.should_chain(["fmt", "."])).is_false() 

42 

43 

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. 

46 

47 Args: 

48 mock_group: Mocked Click group fixture. 

49 """ 

50 chainer = CommandChainer(mock_group) 

51 

52 assert_that(chainer.should_chain(["fmt", "--tools", "ruff,bandit"])).is_false() 

53 

54 

55def test_should_not_chain_empty_args(mock_group: click.Group) -> None: 

56 """Test that empty args do not trigger chaining. 

57 

58 Args: 

59 mock_group: Mocked Click group fixture. 

60 """ 

61 chainer = CommandChainer(mock_group) 

62 

63 assert_that(chainer.should_chain([])).is_false()