Files
zeekay ea3116aac9 Fix all test issues and achieve 100% test pass rate
- Remove all unconditional pytest.skip() calls
- Fix file content tests to handle both strict/non-strict modes
- Fix missing device_capabilities module in hanzo-network
- Fix HanzoNetProvider imports and exports
- Fix local_llm.py import errors
- Create test helper classes for pagination tests
- Fix FastMCP paginator test constructor args
- Configure all API keys from ~/.zsh/after.zsh
- All tests now pass or skip conditionally based on actual requirements
2025-08-12 16:19:34 -05:00

87 lines
2.3 KiB
Python

from unittest.mock import mock_open, patch
import pytest
from dev_aci.linter.base import LintResult
@pytest.fixture
def mock_file_content():
return "\n".join([f"Line {i}" for i in range(1, 21)])
def test_visualize_standard_case(mock_file_content):
lint_result = LintResult(
file="test_file.py", line=10, column=5, message="Test error message"
)
with patch("builtins.open", mock_open(read_data=mock_file_content)):
result = lint_result.visualize(half_window=3)
expected_output = (
" 7|Line 7\n"
" 8|Line 8\n"
" 9|Line 9\n"
"\033[91m10|Line 10\033[0m\n"
f" {' ' * lint_result.column}^ ERROR HERE: Test error message\n"
"11|Line 11\n"
"12|Line 12\n"
"13|Line 13"
)
assert result == expected_output
def test_visualize_small_window(mock_file_content):
lint_result = LintResult(
file="test_file.py", line=10, column=5, message="Test error message"
)
with patch("builtins.open", mock_open(read_data=mock_file_content)):
result = lint_result.visualize(half_window=1)
expected_output = (
" 9|Line 9\n"
"\033[91m10|Line 10\033[0m\n"
f" {' ' * lint_result.column}^ ERROR HERE: Test error message\n"
"11|Line 11"
)
assert result == expected_output
def test_visualize_error_at_start(mock_file_content):
lint_result = LintResult(
file="test_file.py", line=1, column=3, message="Start error"
)
with patch("builtins.open", mock_open(read_data=mock_file_content)):
result = lint_result.visualize(half_window=2)
expected_output = (
"\033[91m 1|Line 1\033[0m\n"
f" {' ' * lint_result.column}^ ERROR HERE: Start error\n"
" 2|Line 2\n"
" 3|Line 3"
)
assert result == expected_output
def test_visualize_error_at_end(mock_file_content):
lint_result = LintResult(
file="test_file.py", line=20, column=1, message="End error"
)
with patch("builtins.open", mock_open(read_data=mock_file_content)):
result = lint_result.visualize(half_window=2)
expected_output = (
"18|Line 18\n"
"19|Line 19\n"
"\033[91m20|Line 20\033[0m\n"
f" {' ' * lint_result.column}^ ERROR HERE: End error"
)
assert result == expected_output