Coverage for tests / unit / cli_utils / command_chainer / test_integration.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-03 18:53 +0000

1"""Integration tests for CommandChainer full workflow.""" 

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_full_workflow_parse_and_group(mock_group: click.Group) -> None: 

12 """Test complete workflow from raw args to command groups. 

13 

14 Args: 

15 mock_group: Mocked Click group fixture. 

16 """ 

17 chainer = CommandChainer(mock_group) 

18 

19 raw_args = ["fmt", ".", ",", "chk", ".", ",", "tst"] 

20 

21 assert_that(chainer.should_chain(raw_args)).is_true() 

22 

23 normalized = chainer.normalize_args(raw_args) 

24 assert_that(normalized).is_equal_to(raw_args) 

25 

26 groups = chainer.group_commands(normalized) 

27 assert_that(groups).is_equal_to([["fmt", "."], ["chk", "."], ["tst"]]) 

28 

29 

30def test_full_workflow_joined_commands(mock_group: click.Group) -> None: 

31 """Test workflow with joined commands like fmt,chk. 

32 

33 Args: 

34 mock_group: Mocked Click group fixture. 

35 """ 

36 chainer = CommandChainer(mock_group) 

37 

38 raw_args = ["fmt,chk", "."] 

39 

40 assert_that(chainer.should_chain(raw_args)).is_true() 

41 

42 normalized = chainer.normalize_args(raw_args) 

43 assert_that(normalized).is_equal_to(["fmt", ",", "chk", "."]) 

44 

45 groups = chainer.group_commands(normalized) 

46 assert_that(groups).is_equal_to([["fmt"], ["chk", "."]])