remove multiline
This commit is contained in:
@@ -4,7 +4,7 @@ Tests the core text processing logic in isolation.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import Mock, patch, MagicMock
|
||||
from unittest.mock import Mock, patch
|
||||
import sys
|
||||
import os
|
||||
|
||||
@@ -13,7 +13,6 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../src'))
|
||||
|
||||
from fixtures.sample_data import *
|
||||
from src.core.text_processor import (
|
||||
process_multiline_text,
|
||||
wrap_text_to_width,
|
||||
render_text_with_stroke,
|
||||
calculate_text_metrics,
|
||||
@@ -97,68 +96,6 @@ class TestWrapTextToWidth:
|
||||
assert "SuperLongWordThatCannotFit" in result
|
||||
|
||||
|
||||
class TestProcessMultilineText:
|
||||
"""Test the process_multiline_text function"""
|
||||
|
||||
@pytest.mark.unit
|
||||
@patch('src.core.text_processor.wrap_text_to_width')
|
||||
def test_process_single_line_text(self, mock_wrap, sample_font):
|
||||
"""Test processing single line text"""
|
||||
mock_wrap.return_value = [SHORT_TEXT]
|
||||
|
||||
with patch('PIL.Image.new'), patch('PIL.ImageDraw.Draw') as mock_draw_class:
|
||||
mock_draw = Mock()
|
||||
mock_draw_class.return_value = mock_draw
|
||||
mock_draw.textbbox.return_value = (0, 0, 100, 20)
|
||||
|
||||
result = process_multiline_text(SHORT_TEXT, sample_font, 200, 100)
|
||||
|
||||
assert result['line_count'] == 1
|
||||
assert result['lines'] == [SHORT_TEXT]
|
||||
assert result['total_height'] == 20
|
||||
|
||||
@pytest.mark.unit
|
||||
@patch('src.core.text_processor.wrap_text_to_width')
|
||||
def test_process_multiline_text_basic(self, mock_wrap, sample_font):
|
||||
"""Test processing actual multiline text"""
|
||||
mock_wrap.side_effect = [['Line 1'], ['Line 2'], ['Line 3'], ['Line 4']]
|
||||
|
||||
with patch('PIL.Image.new'), patch('PIL.ImageDraw.Draw') as mock_draw_class:
|
||||
mock_draw = Mock()
|
||||
mock_draw_class.return_value = mock_draw
|
||||
mock_draw.textbbox.return_value = (0, 0, 80, 20)
|
||||
|
||||
result = process_multiline_text(MULTILINE_TEXT, sample_font, 200, 200)
|
||||
|
||||
assert result['line_count'] == 4
|
||||
assert len(result['lines']) == 4
|
||||
assert result['total_height'] == 80 # 4 lines * 20 height
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_process_empty_text(self, sample_font):
|
||||
"""Test processing empty text"""
|
||||
result = process_multiline_text("", sample_font, 200, 100)
|
||||
|
||||
assert result['line_count'] == 1
|
||||
assert result['lines'] == [""]
|
||||
|
||||
@pytest.mark.unit
|
||||
@patch('src.core.text_processor.wrap_text_to_width')
|
||||
def test_process_height_limit_exceeded(self, mock_wrap, sample_font):
|
||||
"""Test text processing when height limit is exceeded"""
|
||||
mock_wrap.side_effect = [['Line 1'], ['Line 2'], ['Line 3'], ['Line 4']]
|
||||
|
||||
with patch('PIL.Image.new'), patch('PIL.ImageDraw.Draw') as mock_draw_class:
|
||||
mock_draw = Mock()
|
||||
mock_draw_class.return_value = mock_draw
|
||||
mock_draw.textbbox.return_value = (0, 0, 80, 30) # Each line is 30px high
|
||||
|
||||
# With max_height=50, only 1 line should fit
|
||||
result = process_multiline_text(MULTILINE_TEXT, sample_font, 200, 50)
|
||||
|
||||
assert result['line_count'] <= 2 # Should stop when height limit reached
|
||||
assert result['total_height'] <= 60 # Should not exceed much
|
||||
|
||||
|
||||
class TestCalculateTextMetrics:
|
||||
"""Test the calculate_text_metrics function"""
|
||||
@@ -416,4 +353,4 @@ class TestOptimizeTextLayout:
|
||||
"""Test optimization with empty text blocks list"""
|
||||
result = optimize_text_layout([], 500, 400)
|
||||
|
||||
assert result == []
|
||||
assert result == []
|
||||
|
||||
Reference in New Issue
Block a user