Coverage for tests / unit / utils / unified_config / test_ordered_tools.py: 100%
23 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 get_ordered_tools function."""
3from __future__ import annotations
5from typing import Any
6from unittest.mock import patch
8from assertpy import assert_that
10from lintro.utils.unified_config import get_ordered_tools
13def test_get_ordered_tools_priority_ordering(mock_empty_tool_order_config: Any) -> None:
14 """Verify tools are ordered by priority (lower values first).
16 Args:
17 mock_empty_tool_order_config: Mock empty tool order configuration.
18 """
19 result = get_ordered_tools(["ruff", "black", "bandit"])
20 assert_that(result).is_equal_to(["black", "ruff", "bandit"])
23def test_get_ordered_tools_alphabetical_ordering() -> None:
24 """Verify alphabetical ordering when strategy is 'alphabetical'."""
25 result = get_ordered_tools(["ruff", "black", "bandit"], tool_order="alphabetical")
26 assert_that(result).is_equal_to(["bandit", "black", "ruff"])
29def test_get_ordered_tools_custom_ordering() -> None:
30 """Verify custom ordering puts specified tools first."""
31 result = get_ordered_tools(
32 ["ruff", "black", "bandit", "mypy"],
33 tool_order=["mypy", "bandit"],
34 )
35 assert_that(result[0]).is_equal_to("mypy")
36 assert_that(result[1]).is_equal_to("bandit")
37 # Remaining tools should be ordered by priority
38 assert_that(result).is_length(4)
41def test_get_ordered_tools_invalid_strategy_falls_back_to_priority() -> None:
42 """Verify invalid strategy argument falls back to priority ordering."""
43 result = get_ordered_tools(
44 ["ruff", "black", "bandit"],
45 tool_order="invalid_strategy",
46 )
47 assert_that(result).is_equal_to(["black", "ruff", "bandit"])
50def test_get_ordered_tools_invalid_config_strategy_falls_back_to_priority() -> None:
51 """Verify invalid strategy in config falls back to priority ordering."""
52 with patch(
53 "lintro.utils.unified_config.get_tool_order_config",
54 return_value={"strategy": "invalid_strategy"},
55 ):
56 result = get_ordered_tools(["ruff", "black", "bandit"])
57 assert_that(result).is_equal_to(["black", "ruff", "bandit"])