This repository was archived by the owner on Sep 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest_helpers.py
More file actions
38 lines (30 loc) · 1.37 KB
/
test_helpers.py
File metadata and controls
38 lines (30 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
import unittest
from thumbnails.cache_backends import DjangoCacheBackend, SimpleCacheBackend
from thumbnails.engines import PillowEngine
from thumbnails.helpers import generate_filename, get_cache_backend, get_engine, get_storage_backend
from thumbnails.images import SourceFile
from thumbnails.storage_backends import DjangoStorageBackend, FilesystemStorageBackend
from .utils import has_django
class HelpersTestCase(unittest.TestCase):
def test_generate_filename(self):
self.assertEqual(
generate_filename(SourceFile('url'), '100x200', 'center'),
['0af', 'a360db703bd5c2fe7c83843ce7738a0a6d37b']
)
self.assertEqual(
generate_filename(SourceFile('url'), '200x200', 'center'),
['851', '521c21fe9709802e9d4eb20a5fe84c18cd3ad']
)
def test_get_engine(self):
self.assertIsInstance(get_engine(), PillowEngine)
def test_get_cache_backend(self):
if has_django():
self.assertIsInstance(get_cache_backend(), DjangoCacheBackend)
else:
self.assertIsInstance(get_cache_backend(), SimpleCacheBackend)
def test_get_storage_backend(self):
if has_django():
self.assertIsInstance(get_storage_backend(), DjangoStorageBackend)
else:
self.assertIsInstance(get_storage_backend(), FilesystemStorageBackend)