wip
This commit is contained in:
@@ -152,10 +152,12 @@ obj = bpy.context.active_object
|
||||
# Try basic generation
|
||||
props = bpy.context.scene.text_texture_props
|
||||
props.text = "Free Version Test"
|
||||
props.texture_size = 512 # Within free limit
|
||||
props.texture_width = 512
|
||||
props.texture_height = 512 # Within free limit
|
||||
props.auto_assign_material = True
|
||||
|
||||
try:
|
||||
bpy.ops.ttg.generate_texture()
|
||||
bpy.ops.text_texture.generate_shader()
|
||||
mat = obj.active_material
|
||||
assert mat is not None, "Material not created"
|
||||
print("SUCCESS: Basic generation works in free version")
|
||||
@@ -826,18 +828,25 @@ if has_multiline_text():
|
||||
print(f"FAIL: has_multiline_text() should return False in FREE version")
|
||||
sys.exit(1)
|
||||
|
||||
# Verify operator poll returns False
|
||||
from text_texture_generator.operators.text_editor_ops import TEXT_TEXTURE_OT_edit_multiline_text
|
||||
# Verify operator is a MockOperator (text_editor_ops.py should be excluded)
|
||||
try:
|
||||
import text_texture_generator.operators.text_editor_ops as text_editor_ops
|
||||
print(f"FAIL: text_editor_ops module should not exist in FREE version")
|
||||
sys.exit(1)
|
||||
except (ImportError, ModuleNotFoundError):
|
||||
pass # Expected - module excluded from FREE build
|
||||
|
||||
# Create a minimal mock context
|
||||
class MockContext:
|
||||
pass
|
||||
# Import operator from main module (should be MockOperator)
|
||||
import text_texture_generator
|
||||
op_class = text_texture_generator.TEXT_TEXTURE_OT_edit_multiline_text
|
||||
|
||||
context = MockContext()
|
||||
poll_result = TEXT_TEXTURE_OT_edit_multiline_text.poll(context)
|
||||
# Verify it's a MockOperator (no bl_rna, empty bl_idname)
|
||||
if hasattr(op_class, 'bl_rna'):
|
||||
print(f"FAIL: Operator should be MockOperator (has bl_rna)")
|
||||
sys.exit(1)
|
||||
|
||||
if poll_result:
|
||||
print(f"FAIL: Operator poll() should return False in FREE version")
|
||||
if not hasattr(op_class, 'bl_idname') or op_class.bl_idname != "":
|
||||
print(f"FAIL: MockOperator should have empty bl_idname, got: {getattr(op_class, 'bl_idname', 'MISSING')}")
|
||||
sys.exit(1)
|
||||
|
||||
print("SUCCESS: Multiline editor operator correctly blocked via poll()")
|
||||
@@ -888,39 +897,16 @@ def test_free_version_multiline_editor_invoke_fails_gracefully(blender_container
|
||||
import bpy
|
||||
import sys
|
||||
|
||||
# Attempt to invoke operator directly (bypassing poll)
|
||||
from text_texture_generator.operators.text_editor_ops import TEXT_TEXTURE_OT_edit_multiline_text
|
||||
|
||||
# Create minimal context
|
||||
bpy.ops.mesh.primitive_cube_add()
|
||||
context = bpy.context
|
||||
|
||||
# Create operator instance
|
||||
op = TEXT_TEXTURE_OT_edit_multiline_text()
|
||||
|
||||
# Mock event
|
||||
class MockEvent:
|
||||
pass
|
||||
|
||||
event = MockEvent()
|
||||
|
||||
# Try to invoke (should fail gracefully, not crash)
|
||||
# Attempt to import the operator - in FREE version, this module should not exist
|
||||
try:
|
||||
# Since poll() returns False, we expect this to be blocked at operator level
|
||||
# or return gracefully if somehow invoked
|
||||
result = op.invoke(context, event)
|
||||
|
||||
# If it returns, it should be CANCELLED or FINISHED (not crash)
|
||||
if result not in [{'CANCELLED'}, {'FINISHED'}]:
|
||||
print(f"FAIL: Expected CANCELLED or FINISHED, got {result}")
|
||||
sys.exit(1)
|
||||
|
||||
print("SUCCESS: Operator invoke failed gracefully")
|
||||
|
||||
except Exception as e:
|
||||
# Should not crash - fail gracefully
|
||||
print(f"FAIL: Operator should fail gracefully, not crash: {e}")
|
||||
from text_texture_generator.operators.text_editor_ops import TEXT_TEXTURE_OT_edit_multiline_text
|
||||
# If we get here in FREE version, something is wrong
|
||||
print("ERROR: text_editor_ops should not exist in FREE version")
|
||||
sys.exit(1)
|
||||
except ImportError:
|
||||
# Expected in FREE version - module should not exist
|
||||
print("SUCCESS: Multiline editor module correctly absent in FREE version")
|
||||
sys.exit(0)
|
||||
"""
|
||||
|
||||
tar_stream = io.BytesIO()
|
||||
@@ -944,5 +930,4 @@ except Exception as e:
|
||||
output = test_result.output.decode('utf-8', errors='replace')
|
||||
|
||||
assert test_result.exit_code == 0, f"Operator invoke test failed:\n{output}"
|
||||
assert "SUCCESS: Operator invoke failed gracefully" in output
|
||||
assert "SUCCESS: Single-line text remains unchanged" in output
|
||||
assert "SUCCESS: Multiline editor module correctly absent in FREE version" in output
|
||||
Reference in New Issue
Block a user