remove multiline

This commit is contained in:
2025-10-13 00:10:24 +02:00
parent 97950f44c1
commit ad55572aa8
21 changed files with 112 additions and 943 deletions

View File

@@ -1,180 +1,47 @@
"""
Unit tests for version-aware text processing behavior.
Tests that FREE version strips newlines while PRO version preserves them.
Unit tests for text content normalization.
"""
import pytest
from unittest.mock import patch
class TestProcessTextContent:
"""Verify newline and whitespace handling for text processing."""
class TestVersionAwareNewlineHandling:
"""Test that text processing behavior differs between FREE and PRO versions"""
@patch('src.core.text_processor.VERSION_TYPE', 'free')
def test_process_text_strips_newlines_in_free_version(self):
"""FREE version should strip newlines and replace with spaces"""
def test_collapses_single_newlines(self):
from src.core.text_processor import process_text_content
text = "Line 1\nLine 2\nLine 3"
text = "Line 1\nLine 2"
result = process_text_content(text)
assert result == "Line 1 Line 2 Line 3", \
f"FREE version must strip newlines, got: {repr(result)}"
@patch('src.core.text_processor.VERSION_TYPE', 'full')
def test_process_text_preserves_newlines_in_pro_version(self):
"""PRO version should preserve newlines for multiline rendering"""
from src.core.text_processor import process_text_content
text = "Line 1\nLine 2\nLine 3"
result = process_text_content(text)
assert result == "Line 1\nLine 2\nLine 3", \
f"PRO version must preserve newlines, got: {repr(result)}"
assert result == "Line 1 Line 2"
@patch('src.core.text_processor.VERSION_TYPE', 'free')
def test_process_text_strips_multiple_consecutive_newlines_in_free(self):
"""FREE version should collapse multiple newlines to single space"""
def test_collapses_multiple_newlines(self):
from src.core.text_processor import process_text_content
text = "Line 1\n\n\nLine 2"
result = process_text_content(text)
assert result == "Line 1 Line 2", \
f"FREE version must collapse multiple newlines, got: {repr(result)}"
@patch('src.core.text_processor.VERSION_TYPE', 'free')
def test_process_text_handles_mixed_whitespace_in_free(self):
"""FREE version should normalize mixed whitespace with newlines"""
assert result == "Line 1 Line 2"
def test_normalizes_mixed_whitespace(self):
from src.core.text_processor import process_text_content
text = "Line 1\n \nLine 2"
text = "Line 1\n \t\nLine 2"
result = process_text_content(text)
# Should have no newlines and normalized spacing
assert "\n" not in result, \
f"FREE version must remove all newlines, got: {repr(result)}"
assert "Line 1" in result and "Line 2" in result, \
f"Must preserve actual text content, got: {repr(result)}"
@patch('src.core.text_processor.VERSION_TYPE', 'full')
def test_process_text_preserves_multiple_newlines_in_pro(self):
"""PRO version should preserve multiple consecutive newlines"""
from src.core.text_processor import process_text_content
text = "Line 1\n\n\nLine 2"
result = process_text_content(text)
assert result == "Line 1\n\n\nLine 2", \
f"PRO version must preserve all newlines, got: {repr(result)}"
assert "\n" not in result
assert result == "Line 1 Line 2"
@patch('src.core.text_processor.VERSION_TYPE', 'free')
def test_process_empty_text_in_free(self):
"""FREE version should handle empty text gracefully"""
def test_handles_empty_string(self):
from src.core.text_processor import process_text_content
result = process_text_content("")
assert result == "", \
f"Empty text should remain empty, got: {repr(result)}"
@patch('src.core.text_processor.VERSION_TYPE', 'free')
def test_process_text_without_newlines_in_free(self):
"""FREE version should pass through text without newlines unchanged"""
assert result == ""
def test_preserves_text_without_newlines(self):
from src.core.text_processor import process_text_content
text = "Single line text"
result = process_text_content(text)
assert result == "Single line text", \
f"Text without newlines should be unchanged, got: {repr(result)}"
"""
Unit tests for version-aware text processing behavior.
Tests that FREE version strips newlines while PRO version preserves them.
"""
import pytest
from unittest.mock import patch
class TestVersionAwareNewlineHandling:
"""Test that text processing behavior differs between FREE and PRO versions"""
@patch('src.utils.constants.VERSION_TYPE', 'free')
def test_process_text_strips_newlines_in_free_version(self):
"""FREE version should strip newlines and replace with spaces"""
from src.core.text_processor import process_text_content
text = "Line 1\nLine 2\nLine 3"
result = process_text_content(text)
assert result == "Line 1 Line 2 Line 3", \
f"FREE version must strip newlines, got: {repr(result)}"
@patch('src.utils.constants.VERSION_TYPE', 'full')
def test_process_text_preserves_newlines_in_pro_version(self):
"""PRO version should preserve newlines for multiline rendering"""
from src.core.text_processor import process_text_content
text = "Line 1\nLine 2\nLine 3"
result = process_text_content(text)
assert result == "Line 1\nLine 2\nLine 3", \
f"PRO version must preserve newlines, got: {repr(result)}"
@patch('src.utils.constants.VERSION_TYPE', 'free')
def test_process_text_strips_multiple_consecutive_newlines_in_free(self):
"""FREE version should collapse multiple newlines to single space"""
from src.core.text_processor import process_text_content
text = "Line 1\n\n\nLine 2"
result = process_text_content(text)
assert result == "Line 1 Line 2", \
f"FREE version must collapse multiple newlines, got: {repr(result)}"
@patch('src.utils.constants.VERSION_TYPE', 'free')
def test_process_text_handles_mixed_whitespace_in_free(self):
"""FREE version should normalize mixed whitespace with newlines"""
from src.core.text_processor import process_text_content
text = "Line 1\n \nLine 2"
result = process_text_content(text)
# Should have no newlines and normalized spacing
assert "\n" not in result, \
f"FREE version must remove all newlines, got: {repr(result)}"
assert "Line 1" in result and "Line 2" in result, \
f"Must preserve actual text content, got: {repr(result)}"
@patch('src.utils.constants.VERSION_TYPE', 'full')
def test_process_text_preserves_multiple_newlines_in_pro(self):
"""PRO version should preserve multiple consecutive newlines"""
from src.core.text_processor import process_text_content
text = "Line 1\n\n\nLine 2"
result = process_text_content(text)
assert result == "Line 1\n\n\nLine 2", \
f"PRO version must preserve all newlines, got: {repr(result)}"
@patch('src.utils.constants.VERSION_TYPE', 'free')
def test_process_empty_text_in_free(self):
"""FREE version should handle empty text gracefully"""
from src.core.text_processor import process_text_content
result = process_text_content("")
assert result == "", \
f"Empty text should remain empty, got: {repr(result)}"
@patch('src.utils.constants.VERSION_TYPE', 'free')
def test_process_text_without_newlines_in_free(self):
"""FREE version should pass through text without newlines unchanged"""
from src.core.text_processor import process_text_content
text = "Single line text"
result = process_text_content(text)
assert result == "Single line text", \
f"Text without newlines should be unchanged, got: {repr(result)}"
assert result == text