Skip to content

Commit e31ac8a

Browse files
committed
Add new tests
1 parent e739d96 commit e31ac8a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/test_creators/test_image_creator.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,40 @@ def test_invalid_font_path():
4545
font_path="invalid_path",
4646
font_size=40
4747
)
48+
49+
def test_apply_noises():
50+
"""Test that noises are properly applied to the image."""
51+
# Create a mock image
52+
test_image = Image.new("RGB", (200, 100), color="white")
53+
54+
# Create a proper noise effect
55+
blur_noise = BlurNoise(blur_radius=2.0)
56+
57+
# Apply the noise to the image
58+
with patch.object(ImageCreator, '_create_base_image', return_value=test_image):
59+
result = ImageCreator.create_image(
60+
text="Test with noise",
61+
font_path="tests/Arial.ttf",
62+
font_size=12,
63+
noises=[blur_noise]
64+
)
65+
66+
# Verify the result is an image
67+
assert isinstance(result, Image.Image)
68+
69+
def test_create_image_with_custom_params():
70+
"""Test creating an image with custom parameters."""
71+
test_image = Image.new("RGB", (300, 150), color="blue")
72+
73+
with patch.object(ImageCreator, '_create_base_image', return_value=test_image):
74+
# Test with various custom parameters
75+
result = ImageCreator.create_image(
76+
text="Custom Test",
77+
font_path="tests/Arial.ttf",
78+
font_size=16,
79+
font_color="red", # String color name instead of tuple
80+
background_color="blue", # String color name instead of tuple
81+
margins=(20, 20, 20, 20) # Wide margins
82+
)
83+
84+
assert isinstance(result, Image.Image)

0 commit comments

Comments
 (0)