Skip to content

Commit 32eb542

Browse files
committed
Add test
1 parent fba83f9 commit 32eb542

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/image/test_plugins.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,50 @@ def test_plugin(self):
6464
f'class="img-thumbnail rounded" not found in {response.content.decode("utf-8")}',
6565
)
6666

67+
def test_img_processing(self):
68+
# Image gets resized if user width and height are provided
69+
plugin = add_plugin(
70+
placeholder=self.placeholder,
71+
plugin_type=ImagePlugin.__name__,
72+
language=self.language,
73+
config={
74+
"picture": {"pk": self.image.id, "model": "filer.Image"},
75+
"width": 50,
76+
"height": 100,
77+
},
78+
)
79+
plugin.initialize_from_form(ImageForm)
80+
plugin.save()
81+
self.publish(self.page, self.language)
82+
83+
with self.login_user_context(self.superuser):
84+
response = self.client.get(self.request_url)
85+
self.assertEqual(response.status_code, 200)
86+
87+
self.assertTrue('/test_file.jpg__50x100_q85_subsampling-2.jpg"' in res)
88+
89+
# Original image is used if NEITHER width nor height are provided
90+
plugin = add_plugin(
91+
placeholder=self.placeholder,
92+
plugin_type=ImagePlugin.__name__,
93+
language=self.language,
94+
config={
95+
"picture": {"pk": self.image.id, "model": "filer.Image"},
96+
},
97+
)
98+
plugin.initialize_from_form(ImageForm)
99+
plugin.save()
100+
self.publish(self.page, self.language)
101+
102+
with self.login_user_context(self.superuser):
103+
response = self.client.get(self.request_url)
104+
self.assertEqual(response.status_code, 200)
105+
from pprint import pprint as pp
106+
res = response.content.decode("utf-8")
107+
108+
self.assertTrue('/test_file.jpg"' in res)
109+
110+
67111
def test_image_form(self):
68112
request = HttpRequest()
69113
request.POST = {

0 commit comments

Comments
 (0)