wip
This commit is contained in:
103
tests/e2e/test_no_stale_imports.py
Normal file
103
tests/e2e/test_no_stale_imports.py
Normal file
@@ -0,0 +1,103 @@
|
||||
"""E2E regression test to ensure multiline text editor feature is completely removed.
|
||||
|
||||
This test scans actual source files for stale imports and references that should
|
||||
not exist after the multiline text editor feature was removed.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def read_file_lines(filepath: Path) -> list[str]:
|
||||
"""Read file and return lines with line numbers."""
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
return f.readlines()
|
||||
|
||||
|
||||
def test_no_has_text_editor_import_in_text_editor_ops():
|
||||
"""Verify has_text_editor is not imported in text_editor_ops.py"""
|
||||
file_path = Path('src/operators/text_editor_ops.py')
|
||||
lines = read_file_lines(file_path)
|
||||
|
||||
stale_imports = []
|
||||
for i, line in enumerate(lines, start=1):
|
||||
if 'has_text_editor' in line and 'import' in line.lower():
|
||||
stale_imports.append((i, line.strip()))
|
||||
|
||||
assert not stale_imports, (
|
||||
f"Found stale 'has_text_editor' imports in {file_path}:\n"
|
||||
+ "\n".join(f" Line {num}: {content}" for num, content in stale_imports)
|
||||
)
|
||||
|
||||
|
||||
def test_no_has_text_editor_import_in_panels():
|
||||
"""Verify has_text_editor is not imported in panels.py"""
|
||||
file_path = Path('src/ui/panels.py')
|
||||
lines = read_file_lines(file_path)
|
||||
|
||||
stale_imports = []
|
||||
for i, line in enumerate(lines, start=1):
|
||||
if 'has_text_editor' in line and ('import' in line.lower() or 'from' in line.lower()):
|
||||
stale_imports.append((i, line.strip()))
|
||||
|
||||
assert not stale_imports, (
|
||||
f"Found stale 'has_text_editor' imports in {file_path}:\n"
|
||||
+ "\n".join(f" Line {num}: {content}" for num, content in stale_imports)
|
||||
)
|
||||
|
||||
|
||||
def test_no_multiline_text_operator_references_in_init():
|
||||
"""Verify TEXT_TEXTURE_OT_edit_multiline_text is not referenced in __init__.py"""
|
||||
file_path = Path('src/__init__.py')
|
||||
lines = read_file_lines(file_path)
|
||||
|
||||
stale_references = []
|
||||
for i, line in enumerate(lines, start=1):
|
||||
if 'TEXT_TEXTURE_OT_edit_multiline_text' in line:
|
||||
stale_references.append((i, line.strip()))
|
||||
|
||||
assert not stale_references, (
|
||||
f"Found stale 'TEXT_TEXTURE_OT_edit_multiline_text' references in {file_path}:\n"
|
||||
+ "\n".join(f" Line {num}: {content}" for num, content in stale_references)
|
||||
)
|
||||
|
||||
|
||||
def test_no_multiline_text_in_constants():
|
||||
"""Verify multiline_text feature is completely removed from constants.py"""
|
||||
file_path = Path('src/utils/constants.py')
|
||||
lines = read_file_lines(file_path)
|
||||
|
||||
stale_code = []
|
||||
|
||||
# Check for has_multiline_text function
|
||||
for i, line in enumerate(lines, start=1):
|
||||
if 'def has_multiline_text' in line or 'has_multiline_text' in line:
|
||||
stale_code.append((i, line.strip()))
|
||||
|
||||
# Check for "multiline_text" in ENABLED_FEATURES
|
||||
content = ''.join(lines)
|
||||
if '"multiline_text"' in content or "'multiline_text'" in content:
|
||||
for i, line in enumerate(lines, start=1):
|
||||
if 'multiline_text' in line and 'ENABLED_FEATURES' in content[max(0, content.find(line)-500):content.find(line)+500]:
|
||||
stale_code.append((i, line.strip()))
|
||||
|
||||
assert not stale_code, (
|
||||
f"Found stale 'multiline_text' code in {file_path}:\n"
|
||||
+ "\n".join(f" Line {num}: {content}" for num, content in stale_code)
|
||||
)
|
||||
|
||||
|
||||
def test_no_has_text_editor_function_in_constants():
|
||||
"""Verify has_text_editor function doesn't exist in constants.py"""
|
||||
file_path = Path('src/utils/constants.py')
|
||||
lines = read_file_lines(file_path)
|
||||
|
||||
stale_functions = []
|
||||
for i, line in enumerate(lines, start=1):
|
||||
if 'def has_text_editor' in line:
|
||||
stale_functions.append((i, line.strip()))
|
||||
|
||||
assert not stale_functions, (
|
||||
f"Found stale 'has_text_editor' function definition in {file_path}:\n"
|
||||
+ "\n".join(f" Line {num}: {content}" for num, content in stale_functions)
|
||||
)
|
||||
48
tests/unit/test_imports.py
Normal file
48
tests/unit/test_imports.py
Normal file
@@ -0,0 +1,48 @@
|
||||
"""Unit tests for import integrity of renamed/removed symbols."""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add src to path for imports
|
||||
src_path = Path(__file__).parent.parent.parent / "src"
|
||||
sys.path.insert(0, str(src_path))
|
||||
|
||||
|
||||
def test_has_multiline_text_function_complete():
|
||||
"""Test that has_multiline_text() is a complete function with body."""
|
||||
from utils.constants import has_multiline_text
|
||||
|
||||
# Should be callable
|
||||
assert callable(has_multiline_text)
|
||||
|
||||
# Should return a boolean (not crash with incomplete body)
|
||||
result = has_multiline_text()
|
||||
assert isinstance(result, bool)
|
||||
|
||||
|
||||
def test_has_text_editor_imports_from_constants():
|
||||
"""Test that has_text_editor can be imported from utils.constants."""
|
||||
from utils.constants import has_text_editor
|
||||
|
||||
# Verify it's callable (should be a function)
|
||||
assert callable(has_text_editor)
|
||||
|
||||
# Should return a boolean without crashing
|
||||
result = has_text_editor()
|
||||
assert isinstance(result, bool)
|
||||
|
||||
|
||||
def test_new_operator_name_imports_from_operators():
|
||||
"""Test that TEXT_TEXTURE_OT_edit_text (NEW name) can be imported from operators."""
|
||||
from src.operators import TEXT_TEXTURE_OT_edit_text
|
||||
|
||||
# Verify it's a Blender operator class
|
||||
assert hasattr(TEXT_TEXTURE_OT_edit_text, 'bl_idname')
|
||||
assert TEXT_TEXTURE_OT_edit_text.bl_idname == 'text_texture.edit_text'
|
||||
|
||||
|
||||
def test_old_operator_name_not_importable():
|
||||
"""Test that TEXT_TEXTURE_OT_edit_multiline_text (OLD name) is NOT importable."""
|
||||
with pytest.raises(ImportError, match="cannot import name 'TEXT_TEXTURE_OT_edit_multiline_text'"):
|
||||
from src.operators import TEXT_TEXTURE_OT_edit_multiline_text
|
||||
Reference in New Issue
Block a user