Coverage for tests / unit / utils / unified_config / test_consistency.py: 100%

17 statements  

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

1"""Tests for validate_config_consistency function.""" 

2 

3from __future__ import annotations 

4 

5from unittest.mock import patch 

6 

7from assertpy import assert_that 

8 

9from lintro.utils.unified_config import validate_config_consistency 

10 

11 

12def test_validate_config_consistency_returns_empty_when_no_effective_line_length() -> ( 

13 None 

14): 

15 """Verify empty list when no effective line length is configured.""" 

16 with patch( 

17 "lintro.utils.config_validation.get_effective_line_length", 

18 return_value=None, 

19 ): 

20 result = validate_config_consistency() 

21 assert_that(result).is_empty() 

22 

23 

24def test_validate_config_consistency_detects_mismatch() -> None: 

25 """Verify warnings are generated for mismatched native configs.""" 

26 with ( 

27 patch( 

28 "lintro.utils.config_validation.get_effective_line_length", 

29 return_value=100, 

30 ), 

31 patch( 

32 "lintro.utils.config_validation._load_native_tool_config", 

33 return_value={"line-length": 88}, 

34 ), 

35 ): 

36 result = validate_config_consistency() 

37 # Should contain at least one warning about the mismatch 

38 assert_that(result).is_instance_of(list) 

39 assert_that(result).is_not_empty() 

40 

41 

42def test_validate_config_consistency_returns_list() -> None: 

43 """Verify the function always returns a list.""" 

44 with ( 

45 patch( 

46 "lintro.utils.config_validation.get_effective_line_length", 

47 return_value=88, 

48 ), 

49 patch( 

50 "lintro.utils.config_validation._load_native_tool_config", 

51 return_value={}, 

52 ), 

53 ): 

54 result = validate_config_consistency() 

55 assert_that(result).is_instance_of(list)