Coverage for tests / unit / utils / unified_config / test_constants.py: 100%
30 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 GLOBAL_SETTINGS and DEFAULT_TOOL_PRIORITIES constants."""
3from __future__ import annotations
5from assertpy import assert_that
7from lintro.utils.unified_config import DEFAULT_TOOL_PRIORITIES, GLOBAL_SETTINGS
9# Tests for GLOBAL_SETTINGS constant
12def test_global_settings_line_length_has_expected_tools() -> None:
13 """Verify line_length setting includes expected tools."""
14 tools = GLOBAL_SETTINGS["line_length"]["tools"]
16 assert_that(tools).contains_key("ruff")
17 assert_that(tools).contains_key("black")
18 assert_that(tools).contains_key("markdownlint")
19 assert_that(tools).contains_key("yamllint")
22def test_global_settings_line_length_has_injectable_tools() -> None:
23 """Verify line_length has a set of injectable tools."""
24 injectable = GLOBAL_SETTINGS["line_length"]["injectable"]
26 assert_that(injectable).contains("ruff")
27 assert_that(injectable).contains("black")
30def test_global_settings_has_multiple_settings() -> None:
31 """Verify GLOBAL_SETTINGS includes multiple setting types."""
32 assert_that(GLOBAL_SETTINGS).contains_key("line_length")
33 assert_that(GLOBAL_SETTINGS).contains_key("target_python")
34 assert_that(GLOBAL_SETTINGS).contains_key("indent_size")
37# Tests for DEFAULT_TOOL_PRIORITIES constant
40def test_default_tool_priorities_formatters_before_linters() -> None:
41 """Verify formatters have lower priority (run first) than linters."""
42 assert_that(DEFAULT_TOOL_PRIORITIES["black"]).is_less_than(
43 DEFAULT_TOOL_PRIORITIES["bandit"],
44 )
45 assert_that(DEFAULT_TOOL_PRIORITIES["black"]).is_less_than(
46 DEFAULT_TOOL_PRIORITIES["bandit"],
47 )
48 assert_that(DEFAULT_TOOL_PRIORITIES["ruff"]).is_less_than(
49 DEFAULT_TOOL_PRIORITIES["bandit"],
50 )
53def test_default_tool_priorities_pytest_runs_last() -> None:
54 """Verify pytest has highest priority (runs last)."""
55 pytest_priority = DEFAULT_TOOL_PRIORITIES["pytest"]
57 for tool, priority in DEFAULT_TOOL_PRIORITIES.items():
58 if tool != "pytest":
59 assert_that(priority).is_less_than(pytest_priority)
62def test_default_tool_priorities_has_expected_tools() -> None:
63 """Verify DEFAULT_TOOL_PRIORITIES includes expected tools."""
64 expected_tools = [
65 "black",
66 "ruff",
67 "markdownlint",
68 "yamllint",
69 "bandit",
70 "pytest",
71 ]
73 for tool in expected_tools:
74 assert_that(DEFAULT_TOOL_PRIORITIES).contains_key(tool)