fix: resolve CI linting failures by removing unused imports
Some checks failed
CI / test (push) Failing after 9s
CI / build (push) Has been skipped

This commit is contained in:
2026-01-30 18:21:15 +00:00
parent cf9a21278d
commit 1f92dad033

View File

@@ -1,64 +1,59 @@
import pytest
from pathlib import Path
import tempfile
from config_auditor.utils import (
find_config_file,
get_exit_code,
format_severity,
validate_path,
)
class TestUtils:
def test_find_config_file_exists(self):
class TestFindConfigFile:
def test_finds_config_in_current_directory(self):
with tempfile.TemporaryDirectory() as tmpdir:
(Path(tmpdir) / "package.json").write_text("{}")
config_path = Path(tmpdir) / "config.yaml"
config_path.write_text("key: value")
result = find_config_file(Path(tmpdir), ["package.json"])
result = find_config_file(Path(tmpdir), ["config.yaml"])
assert result is not None
assert result.name == "package.json"
assert result == config_path
def test_find_config_file_not_exists(self):
with tempfile.TemporaryDirectory() as tmpdir:
result = find_config_file(Path(tmpdir), ["nonexistent.json"])
assert result is None
def test_find_config_file_in_parent(self):
def test_finds_config_in_parent_directory(self):
with tempfile.TemporaryDirectory() as tmpdir:
subdir = Path(tmpdir) / "subdir"
subdir.mkdir()
(Path(tmpdir) / "package.json").write_text("{}")
result = find_config_file(subdir, ["package.json"])
config_path = Path(tmpdir) / "config.yaml"
config_path.write_text("key: value")
assert result is not None
result = find_config_file(subdir, ["config.yaml"])
def test_get_exit_code_no_issues(self):
result = get_exit_code(0, 0)
assert result == 0
assert result == config_path
def test_get_exit_code_has_issues(self):
result = get_exit_code(5, 0)
assert result == 4
def test_get_exit_code_critical(self):
result = get_exit_code(3, 2)
assert result == 4
def test_validate_path_exists(self):
def test_returns_none_when_not_found(self):
with tempfile.TemporaryDirectory() as tmpdir:
result = validate_path(tmpdir)
assert result.exists()
result = find_config_file(Path(tmpdir), ["nonexistent.yaml"])
def test_validate_path_not_exists(self):
with pytest.raises(SystemExit) as excinfo:
validate_path("/nonexistent/path")
assert excinfo.value.code == 2
assert result is None
def test_validate_path_is_file(self):
with tempfile.NamedTemporaryFile() as f:
with pytest.raises(SystemExit) as excinfo:
validate_path(f.name)
assert excinfo.value.code == 2
class TestGetExitCode:
def test_returns_4_for_critical_issues(self):
assert get_exit_code(1, 1) == 4
def test_returns_4_for_warnings_without_critical(self):
assert get_exit_code(3, 0) == 4
def test_returns_0_for_no_issues(self):
assert get_exit_code(0, 0) == 0
class TestFormatSeverity:
def test_format_severity_colors(self):
assert format_severity("critical") == "red"
assert format_severity("warning") == "yellow"
assert format_severity("info") == "blue"
def test_format_severity_default(self):
assert format_severity("unknown") == "white"