WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit fbb889f

Browse files
thumbnail test for easy-thumbnails
1 parent d637505 commit fbb889f

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ coverage.xml
2020
.tox
2121
.venv/
2222
cache/
23+
tests/files/sample.jpg.*.jpg

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ dependencies = [
3939
[project.optional-dependencies]
4040
test = [
4141
"python-ldap",
42+
"sorl-thumbnail",
43+
"easy-thumbnails",
4244
"unicodecsv",
4345
"python-card-me",
4446
"django-tinymce",

tests/test_mailing.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from django.core import mail
1212
from django.core.exceptions import ValidationError
1313
from django.utils.timezone import now
14-
from django.test.utils import override_settings
14+
from django.test.utils import override_settings, modify_settings
1515

1616
from newsletter.models import (
1717
Newsletter, Subscription, Submission, Message, Article, Attachment, SubscriptionGenerator,
@@ -131,6 +131,22 @@ def test_image_thumbnail(self):
131131
self.assertNotRegex(html, image_above_regex)
132132
self.assertRegex(html, image_below_regex)
133133

134+
@modify_settings(INSTALLED_APPS={'append': 'easy_thumbnails', 'remove': 'sorl.thumbnail'})
135+
@override_settings(NEWSLETTER_THUMBNAIL='easy-thumbnails')
136+
def test_image_thumbnail_easy(self):
137+
a = self.make_article()
138+
a.image = os.path.join('tests', 'files', 'sample.jpg')
139+
a.save()
140+
_, _, html = render_message(self.m)
141+
self.assertEqual(a.image_thumbnail_size(), '200x200')
142+
self.assertIn('src="https://example.com/tests/files/sample.jpg.200x200_q85.jpg"', html)
143+
144+
a.image_thumbnail_width = 400
145+
a.save()
146+
_, _, html = render_message(self.m)
147+
self.assertEqual(a.image_thumbnail_size(), '400x300')
148+
self.assertIn('src="https://example.com/tests/files/sample.jpg.400x300_q85.jpg"', html)
149+
134150
@override_settings(NEWSLETTER_USE_HTTPS=False)
135151
def test_http(self):
136152
a = self.make_article()

0 commit comments

Comments
 (0)