No image
42 | {% endthumbnail %} 43 | 44 | Nesting tags and setting size (geometry) for width only:: 45 | 46 | {% thumbnail item.image "1000" as big %} 47 | {% thumbnail item.image "50x50" crop="center" as small %} 48 |Undefined behaviour
74 |fail
6 | {% endthumbnail %} 7 | -------------------------------------------------------------------------------- /tests/thumbnail_tests/templates/thumbnail20a.html: -------------------------------------------------------------------------------- 1 | {% load thumbnail %}empty{{ im }}
6 | {% endthumbnail %} 7 | {% endspaceless %} 8 | -------------------------------------------------------------------------------- /tests/thumbnail_tests/templates/thumbnail6.html: -------------------------------------------------------------------------------- 1 | {% load thumbnail %}{% spaceless %} 2 | {% thumbnail item.image "100x100" as th %} 3 | {% thumbnail item.image "400x400" as im %} 4 |empty
6 | {% endthumbnail %} 7 | {% endspaceless %} 8 | -------------------------------------------------------------------------------- /tests/thumbnail_tests/templates/thumbnaild1.html: -------------------------------------------------------------------------------- 1 | {% load thumbnail %}{% spaceless %} 2 | 3 | {% thumbnail anything "200x100" as im %} 4 |NOT
{% endif %} 6 | {% endspaceless %} 7 | -------------------------------------------------------------------------------- /tests/thumbnail_tests/templates/thumbnaild3.html: -------------------------------------------------------------------------------- 1 | {% load thumbnail %}{% spaceless %} 2 | {% thumbnail "" "x400" as im %} 3 |empty
') 153 | 154 | 155 | class TemplateTestCaseClient(TestCase): 156 | def test_empty_error(self): 157 | with override_settings(THUMBNAIL_DEBUG=False): 158 | from django.core.mail import outbox 159 | 160 | client = Client() 161 | response = client.get('/thumbnail9.html') 162 | self.assertEqual(response.content.strip(), b'empty
') 163 | self.assertEqual(outbox[0].subject, '[sorl-thumbnail] ERROR: Unknown URL') 164 | 165 | end = outbox[0].body.split('\n\n')[-2].split(':')[1].strip() 166 | 167 | self.assertEqual(end, '[Errno 2] No such file or directory') 168 | 169 | 170 | class TemplateTestCaseTemplateTagAlias(BaseTestCase): 171 | """Testing alternative template tag (alias).""" 172 | 173 | def test_model(self): 174 | item = Item.objects.get(image='500x500.jpg') 175 | val = render_to_string( 176 | 'thumbnail1_alias.html', {'item': item} 177 | ).strip() 178 | self.assertEqual( 179 | val, 180 | '