This commit is contained in:
2025-10-13 17:01:37 +02:00
parent 57b55b10a2
commit 09f33e461d
7 changed files with 91 additions and 22 deletions

View File

@@ -1027,6 +1027,42 @@ class TestGeneratePreview:
# The image name contains dimensions
call_args = mock_bpy.data.images.new.call_args[0]
assert "128x128" in call_args[0]
def test_preview_defaults_to_texture_resolution(self):
"""Preview falls back to full texture dimensions when none provided."""
with patch('PIL.Image') as mock_pil_image_module, \
patch('PIL.ImageDraw') as mock_pil_imagedraw_module, \
patch('PIL.ImageFont') as mock_pil_imagefont_module, \
patch('src.core.generation_engine.bpy') as mock_bpy:
mock_pil_image = MagicMock()
mock_pil_image.size = (256, 128)
mock_pil_image.getdata.return_value = [(255, 255, 255, 255)] * (256 * 128)
mock_pil_image.transpose.return_value = mock_pil_image
mock_pil_image_module.new.return_value = mock_pil_image
mock_pil_image_module.FLIP_TOP_BOTTOM = 1
mock_draw = MagicMock()
mock_draw.textbbox.return_value = (0, 0, 50, 25)
mock_pil_imagedraw_module.Draw.return_value = mock_draw
mock_font = MagicMock()
mock_pil_imagefont_module.load_default.return_value = mock_font
mock_blender_image = MagicMock()
mock_blender_image.pixels = [0.0] * (256 * 128 * 4)
mock_bpy.data.images.new.return_value = mock_blender_image
mock_bpy.data.images.__contains__.return_value = False
props = create_mock_props(text="AutoSize")
props.texture_width = 256
props.texture_height = 128
result = generate_preview(props)
assert result is not None
call_args = mock_bpy.data.images.new.call_args[0]
assert "256x128" in call_args[0]
def test_preview_uses_same_props(self):
"""Test that preview uses same properties as main generation."""