From 3001069254a320fb3a2fa519dc61e14b329cc00f Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Tue, 4 Jun 2013 23:34:26 -0400 Subject: [PATCH] Test stringification of LazyImageCacheFiles --- tests/test_cachefiles.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/test_cachefiles.py b/tests/test_cachefiles.py index 3cd6af6..4338a82 100644 --- a/tests/test_cachefiles.py +++ b/tests/test_cachefiles.py @@ -1,11 +1,12 @@ from django.conf import settings from hashlib import md5 -from imagekit.cachefiles import ImageCacheFile +from imagekit.cachefiles import ImageCacheFile, LazyImageCacheFile from imagekit.cachefiles.backends import Simple from nose.tools import raises, eq_ from .imagegenerators import TestSpec from .utils import (assert_file_is_truthy, assert_file_is_falsy, - DummyAsyncCacheFileBackend, get_unique_image_file) + DummyAsyncCacheFileBackend, get_unique_image_file, + get_image_file) def test_no_source_falsiness(): @@ -73,3 +74,15 @@ def test_memcached_cache_key(): settings.IMAGEKIT_CACHE_PREFIX, '1' * (200 - len(':') - 32 - len(settings.IMAGEKIT_CACHE_PREFIX)), md5('%s%s-state' % (settings.IMAGEKIT_CACHE_PREFIX, filename)).hexdigest())) + + +def test_lazyfile_stringification(): + file = LazyImageCacheFile('testspec', source=None) + eq_(str(file), '') + eq_(repr(file), '') + + source_file = get_image_file() + file = LazyImageCacheFile('testspec', source=source_file) + file.name = 'a.jpg' + eq_(str(file), 'a.jpg') + eq_(repr(file), '')