move to legacy addon
This commit is contained in:
1
tests/e2e/__init__.py
Normal file
1
tests/e2e/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""End-to-end tests for addon package validation."""
|
||||
BIN
tests/e2e/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
tests/e2e/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
72
tests/e2e/test_bl_info_parsing.py
Normal file
72
tests/e2e/test_bl_info_parsing.py
Normal file
@@ -0,0 +1,72 @@
|
||||
"""E2E test for bl_info parsing in built addon package."""
|
||||
import ast
|
||||
import zipfile
|
||||
import subprocess
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_built_package_bl_info_is_parseable():
|
||||
"""
|
||||
CRITICAL E2E TEST: Validates that the built addon package has a parseable bl_info.
|
||||
This test rebuilds the package, extracts it, and parses bl_info exactly as Blender does.
|
||||
"""
|
||||
project_root = Path(__file__).parent.parent.parent
|
||||
|
||||
# Step 1: Rebuild the package to ensure latest code
|
||||
result = subprocess.run(
|
||||
["python", "build/build_addon.py", "--type", "full"],
|
||||
cwd=project_root,
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
assert result.returncode == 0, f"Build failed: {result.stderr}"
|
||||
|
||||
# Step 2: Extract the built package
|
||||
dist_zip = project_root / "dist" / "text_texture_generator_v1.0.0.zip"
|
||||
assert dist_zip.exists(), f"Built package not found: {dist_zip}"
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
with zipfile.ZipFile(dist_zip, 'r') as z:
|
||||
z.extractall(tmpdir)
|
||||
|
||||
init_file = Path(tmpdir) / "text_texture_generator" / "__init__.py"
|
||||
assert init_file.exists(), f"__init__.py not found in package"
|
||||
|
||||
# Step 3: Read and parse exactly as Blender does
|
||||
content = init_file.read_text()
|
||||
tree = ast.parse(content)
|
||||
|
||||
bl_info_found = False
|
||||
for node in tree.body:
|
||||
if isinstance(node, ast.Assign):
|
||||
for target in node.targets:
|
||||
if isinstance(target, ast.Name) and target.id == 'bl_info':
|
||||
bl_info_found = True
|
||||
|
||||
# This is THE critical test - ast.literal_eval() exactly as Blender uses
|
||||
try:
|
||||
parsed_bl_info = ast.literal_eval(node.value)
|
||||
|
||||
# Validate required keys
|
||||
assert "name" in parsed_bl_info, "bl_info missing 'name'"
|
||||
assert "author" in parsed_bl_info, "bl_info missing 'author'"
|
||||
assert "version" in parsed_bl_info, "bl_info missing 'version'"
|
||||
assert "blender" in parsed_bl_info, "bl_info missing 'blender'"
|
||||
|
||||
# Success!
|
||||
print(f"\n✅ bl_info parsed successfully:")
|
||||
print(f" name: {parsed_bl_info['name']}")
|
||||
print(f" version: {parsed_bl_info['version']}")
|
||||
|
||||
except ValueError as e:
|
||||
# Print diagnostic info before failing
|
||||
print(f"\n❌ FAILED at line {node.lineno}")
|
||||
print(f"Error: {e}")
|
||||
print(f"\nProblematic AST node:")
|
||||
print(ast.dump(node.value, indent=2))
|
||||
print(f"\nFirst 30 lines of __init__.py:")
|
||||
print('\n'.join(content.split('\n')[:30]))
|
||||
raise AssertionError(f"bl_info failed ast.literal_eval() at line {node.lineno}: {e}")
|
||||
|
||||
assert bl_info_found, "bl_info not found in __init__.py"
|
||||
Reference in New Issue
Block a user