text fitting pro feature

This commit is contained in:
2025-10-10 14:41:18 +02:00
parent 0edf324335
commit 596f640912
23 changed files with 909 additions and 86 deletions

View File

@@ -15,7 +15,7 @@ def test_built_package_bl_info_is_parseable():
# Step 1: Rebuild the package to ensure latest code
result = subprocess.run(
["python", "build/build_addon.py", "--type", "full"],
["python", "scripts/build_addon.py"],
cwd=project_root,
capture_output=True,
text=True
@@ -69,4 +69,39 @@ def test_built_package_bl_info_is_parseable():
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"
assert bl_info_found, "bl_info not found in __init__.py"
def test_manifest_not_in_source():
"""Verify blender_manifest.toml is NOT in source directory (legacy mode)."""
manifest_path = Path(__file__).parent.parent.parent / "src" / "blender_manifest.toml"
assert not manifest_path.exists(), \
"blender_manifest.toml should not exist in src/ for legacy addon mode"
def test_manifest_not_in_built_package():
"""Verify blender_manifest.toml is NOT in built packages (both FREE and FULL)."""
project_root = Path(__file__).parent.parent.parent
# Check both FREE and FULL versions
zip_files = [
project_root / "dist" / "text_texture_generator_v1.0.0.zip", # FULL
project_root / "dist" / "text_texture_generator_v1.0.0_free.zip", # FREE
]
for zip_path in zip_files:
if not zip_path.exists():
continue # Skip if not built yet
with zipfile.ZipFile(zip_path, 'r') as z:
files = z.namelist()
manifest_files = [f for f in files if 'blender_manifest.toml' in f]
assert len(manifest_files) == 0, \
f"blender_manifest.toml should not be in {zip_path.name}. Found: {manifest_files}"
def test_manifest_template_not_exists():
"""Verify blender_manifest.toml.template doesn't exist (prevents regeneration)."""
template_path = Path(__file__).parent.parent.parent / "build" / "templates" / "blender_manifest.toml.template"
assert not template_path.exists(), \
"blender_manifest.toml.template should not exist to prevent automatic regeneration during builds"

View File

@@ -347,7 +347,66 @@ print("SUCCESS: Image overlay properly blocked")
output = test_result.output.decode('utf-8', errors='replace')
assert test_result.exit_code == 0, f"Overlay block test failed:\n{output}"
assert "SUCCESS: Image overlay properly blocked" in output
def test_free_version_blocks_text_fitting(blender_container, addon_package):
"""
SPECIFICATION: Free version MUST block text fitting functionality.
Expected behavior (VERSION_TYPE="free"):
- "text_fitting" NOT in ENABLED_FEATURES
- has_text_fitting() returns False
- Text fitting controls unavailable
- UI shows "🔒 PRO" on text fitting controls
Current state (VERSION_TYPE="full"):
- Test SKIPS (text_fitting is available)
"""
version_type, enabled_features = get_version_type(blender_container, addon_package)
if version_type == "full":
pytest.skip("Test requires VERSION_TYPE='free' - currently 'full' (specification test)")
script_content = """
import bpy
import sys
# Verify text_fitting NOT enabled
from text_texture_generator.utils.constants import ENABLED_FEATURES, has_text_fitting
if "text_fitting" in ENABLED_FEATURES:
print(f"FAIL: text_fitting should NOT be in ENABLED_FEATURES for free version")
sys.exit(1)
# Verify has_text_fitting() returns False
if has_text_fitting():
print(f"FAIL: has_text_fitting() should return False for free version")
sys.exit(1)
print("SUCCESS: Text fitting properly blocked")
"""
tar_stream = io.BytesIO()
with tarfile.open(fileobj=tar_stream, mode='w') as tar:
script_info = tarfile.TarInfo(name='test_text_fitting.py')
script_bytes = script_content.encode('utf-8')
script_info.size = len(script_bytes)
tar.addfile(script_info, io.BytesIO(script_bytes))
tar_stream.seek(0)
blender_container.put_archive('/addon-test', tar_stream)
test_cmd = [
"/usr/local/bin/run_blender.sh",
"--background",
"--python",
"/addon-test/test_text_fitting.py"
]
test_result = blender_container.exec_run(test_cmd, workdir="/addon-test")
output = test_result.output.decode('utf-8', errors='replace')
assert test_result.exit_code == 0, f"Text fitting block test failed:\n{output}"
assert "SUCCESS: Text fitting properly blocked" in output
def test_free_version_texture_size_limited(blender_container, addon_package):