Skip to content

Commit

Permalink
Move test utilities outside of the tests dir
Browse files Browse the repository at this point in the history
It's less confusing -- this way it doesn't look like it is a module
testing the easy_thumbnails utils (and if utils tests get added, they
can go here instead).
  • Loading branch information
SmileyChris committed Aug 29, 2012
1 parent ceb1624 commit a93aa5f
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 31 deletions.
File renamed without changes.
7 changes: 3 additions & 4 deletions easy_thumbnails/tests/aliases.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from django.db import models
from django.core.files.storage import get_storage_class

from easy_thumbnails import files, fields, signals, signal_handlers
from easy_thumbnails.alias import aliases
from easy_thumbnails.conf import settings
from easy_thumbnails.tests import utils
from easy_thumbnails import test


class Profile(models.Model):
Expand All @@ -15,7 +14,7 @@ class Meta:
app_label = 'some_app'


class BaseTest(utils.BaseTest):
class BaseTest(test.BaseTest):
create_file = False

def setUp(self):
Expand Down Expand Up @@ -43,7 +42,7 @@ def setUp(self):
aliases.populate_from_settings()

if self.create_file:
self.storage = utils.TemporaryStorage()
self.storage = test.TemporaryStorage()
# Save a test image.
self.create_image(self.storage, 'avatars/test.jpg')
# Set the test model to use the current temporary storage.
Expand Down
10 changes: 5 additions & 5 deletions easy_thumbnails/tests/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.core.files.base import ContentFile
from django.db import models

from easy_thumbnails.tests.utils import BaseTest, TemporaryStorage
from easy_thumbnails import test
from easy_thumbnails.fields import ThumbnailerField
from easy_thumbnails.exceptions import InvalidImageFormatError

Expand All @@ -12,10 +12,10 @@ class TestModel(models.Model):
avatar = ThumbnailerField(upload_to='avatars')


class ThumbnailerFieldTest(BaseTest):
class ThumbnailerFieldTest(test.BaseTest):
def setUp(self):
BaseTest.setUp(self)
self.storage = TemporaryStorage()
super(ThumbnailerFieldTest, self).setUp()
self.storage = test.TemporaryStorage()
# Save a test image.
self.create_image(self.storage, 'avatars/avatar.jpg')
# Set the test model to use the current temporary storage.
Expand All @@ -24,7 +24,7 @@ def setUp(self):

def tearDown(self):
self.storage.delete_temporary_storage()
BaseTest.tearDown(self)
super(ThumbnailerFieldTest, self).tearDown()

def test_generate_thumbnail(self):
instance = TestModel(avatar='avatars/avatar.jpg')
Expand Down
9 changes: 4 additions & 5 deletions easy_thumbnails/tests/files.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
from os import path

from easy_thumbnails import files, utils, signals
from easy_thumbnails.tests import utils as test_utils
from easy_thumbnails import files, utils, signals, test
from easy_thumbnails.conf import settings
try:
from PIL import Image
except ImportError:
import Image


class FilesTest(test_utils.BaseTest):
class FilesTest(test.BaseTest):

def setUp(self):
super(FilesTest, self).setUp()
self.storage = test_utils.TemporaryStorage()
self.remote_storage = test_utils.FakeRemoteStorage()
self.storage = test.TemporaryStorage()
self.remote_storage = test.FakeRemoteStorage()

# Save a test image in both storages.
filename = self.create_image(self.storage, 'test.jpg')
Expand Down
7 changes: 3 additions & 4 deletions easy_thumbnails/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
"""Tests for the models module.
"""

from easy_thumbnails import utils
from easy_thumbnails import utils, test
from easy_thumbnails.models import Thumbnail, Source
from easy_thumbnails.tests import utils as test_utils


class FileManagerTest(test_utils.BaseTest):
class FileManagerTest(test.BaseTest):
"""Test for FileManager"""

def setUp(self):
super(FileManagerTest, self).setUp()

self.storage = test_utils.TemporaryStorage()
self.storage = test.TemporaryStorage()
self.storage_hash = utils.get_storage_hash(self.storage)
self.source = Source.objects.create(
name='Test source',
Expand Down
5 changes: 2 additions & 3 deletions easy_thumbnails/tests/source_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import Image
import ImageChops

from easy_thumbnails import source_generators
from easy_thumbnails.tests import utils as test_utils
from easy_thumbnails import source_generators, test

EXIF_REFERENCE = '/9j/4AAQSkZJRgABAQEASABIAAD/4QAiRXhpZgAASUkqAAgAAAABABIBAwABAAAAAQAAAAAAAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH//gAdQ3JlYXRlZCB3aXRoIEdJTVAgb24gYSBNYWMA/8AACwgAHgAeAQERAP/EABgAAAMBAQAAAAAAAAAAAAAAAAAICgkL/8QAPhAAAAIGBgQGEwAAAAAAAAAABxYABAUGFRcICRMUGCUDChkaIyc3ZoinJDQ1OUVHSVdYZ2imqLjI1tfm5//aAAgBAQAAPwC/hBBBIA9tpWdekz1M0ffxQlftVwNon0jKCYGDKMrzHESXxmaY3jgrvO9ES8MQguqx8ndVksNgqdzYLDZah2Ay1W8XW9LVuu6dYWNMU5xtE8HJXS4eYuGM7RnJXea98hBRh3d5ktS73eKL3atha2/D2tlobNAMbVJ3zm+5gffaiKruy/tsfDd/e0QAbdYb2CInvNVN4QsVuFKC8fs/5Fn2ejvMmkpyVyUGIrFacRL5R3jjZcMeUReBMt/6sus03i6dnEng7wdy38ZGIOYuIM+8wgQKJRkhznj5n8CwXNtVNmX67Orf99TVROQLrR3f16c3Rm+Tyj6m/wBqMflRehN9XCX+J//Z'
EXIF_ORIENTATION = {
Expand Down Expand Up @@ -39,7 +38,7 @@ def image_from_b64(data):
return Image.open(StringIO(data.decode('base64')))


class PilImageTest(test_utils.BaseTest):
class PilImageTest(test.BaseTest):

def test_not_image(self):
"""
Expand Down
10 changes: 5 additions & 5 deletions easy_thumbnails/tests/templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
except ImportError:
import Image

from easy_thumbnails import test
from easy_thumbnails.conf import settings
from easy_thumbnails.tests.utils import BaseTest, TemporaryStorage
from easy_thumbnails.files import get_thumbnailer


class ThumbnailTagTest(BaseTest):
class ThumbnailTagTest(test.BaseTest):
restore_settings = ['THUMBNAIL_DEBUG', 'TEMPLATE_DEBUG']

def setUp(self):
BaseTest.setUp(self)
self.storage = TemporaryStorage()
super(ThumbnailTagTest, self).setUp()
self.storage = test.TemporaryStorage()
# Save a test image.
self.filename = self.create_image(self.storage, 'test.jpg')

Expand All @@ -23,7 +23,7 @@ def setUp(self):

def tearDown(self):
self.storage.delete_temporary_storage()
BaseTest.tearDown(self)
super(ThumbnailTagTest, self).tearDown()

def render_template(self, source):
source_image = get_thumbnailer(self.storage, self.filename)
Expand Down
8 changes: 3 additions & 5 deletions easy_thumbnails/tests/widgets.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from easy_thumbnails import widgets
from easy_thumbnails.files import get_thumbnailer
from easy_thumbnails.tests import utils as test_utils
from easy_thumbnails import widgets, test
from django.forms.widgets import ClearableFileInput


class ImageClearableFileInput(test_utils.BaseTest):
class ImageClearableFileInput(test.BaseTest):

def setUp(self):
super(ImageClearableFileInput, self).setUp()
self.storage = test_utils.TemporaryStorage()
self.storage = test.TemporaryStorage()

def tearDown(self):
self.storage.delete_temporary_storage()
Expand Down

0 comments on commit a93aa5f

Please sign in to comment.