-
-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #348 from mariocesar/tests/restructure
Restructure test suite
- Loading branch information
Showing
20 changed files
with
1,103 additions
and
1,411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
|
||
import pytest | ||
|
||
from sorl.thumbnail import get_thumbnail | ||
from sorl.thumbnail.conf import settings | ||
from sorl.thumbnail.images import ImageFile | ||
from sorl.thumbnail.engines.pil_engine import Engine as PILEngine | ||
|
||
from .utils import BaseStorageTestCase | ||
|
||
|
||
pytestmark = pytest.mark.django_db | ||
|
||
|
||
class AlternativeResolutionsTest(BaseStorageTestCase): | ||
name = 'retina.jpg' | ||
|
||
def setUp(self): | ||
settings.THUMBNAIL_ALTERNATIVE_RESOLUTIONS = [1.5, 2] | ||
super(AlternativeResolutionsTest, self).setUp() | ||
self.maxDiff = None | ||
|
||
def tearDown(self): | ||
super(AlternativeResolutionsTest, self).tearDown() | ||
settings.THUMBNAIL_ALTERNATIVE_RESOLUTIONS = [] | ||
|
||
def test_retina(self): | ||
get_thumbnail(self.image, '50x50') | ||
|
||
actions = [ | ||
'exists: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d.jpg', | ||
|
||
# save regular resolution, same as in StorageTestCase | ||
'open: retina.jpg', | ||
'save: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d.jpg', | ||
'get_available_name: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d.jpg', | ||
'exists: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d.jpg', | ||
|
||
# save the 1.5x resolution version | ||
'save: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d@1.5x.jpg', | ||
'get_available_name: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d@1.5x.jpg', | ||
'exists: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d@1.5x.jpg', | ||
|
||
# save the 2x resolution version | ||
'save: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d@2x.jpg', | ||
'get_available_name: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d@2x.jpg', | ||
'exists: test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d@2x.jpg' | ||
] | ||
self.assertEqual(self.log, actions) | ||
|
||
path = os.path.join(settings.MEDIA_ROOT, | ||
'test/cache/91/bb/91bb06cf9169e4c52132bb113f2d4c0d@1.5x.jpg') | ||
|
||
with open(path) as fp: | ||
engine = PILEngine() | ||
self.assertEqual(engine.get_image_size(engine.get_image(ImageFile(file_=fp))), (75, 75)) |
Oops, something went wrong.