2013-02-26 03:15:57 +00:00
|
|
|
from imagekit.cachefiles import ImageCacheFile
|
2013-03-15 02:23:47 +00:00
|
|
|
from nose.tools import raises
|
2013-02-26 03:15:57 +00:00
|
|
|
from .imagegenerators import TestSpec
|
2013-03-15 04:49:44 +00:00
|
|
|
from .utils import (assert_file_is_truthy, assert_file_is_falsy,
|
|
|
|
|
DummyAsyncCacheFileBackend, get_unique_image_file)
|
2013-02-26 03:15:57 +00:00
|
|
|
|
|
|
|
|
|
2013-03-15 04:49:44 +00:00
|
|
|
def test_no_source_falsiness():
|
2013-02-26 03:15:57 +00:00
|
|
|
"""
|
2013-03-15 04:49:44 +00:00
|
|
|
Ensure cache files generated from sourceless specs are falsy.
|
|
|
|
|
|
2013-02-26 03:15:57 +00:00
|
|
|
"""
|
|
|
|
|
spec = TestSpec(source=None)
|
|
|
|
|
file = ImageCacheFile(spec)
|
2013-03-15 02:23:47 +00:00
|
|
|
assert_file_is_falsy(file)
|
2013-02-26 03:34:24 +00:00
|
|
|
|
|
|
|
|
|
2013-03-15 04:49:44 +00:00
|
|
|
def test_sync_backend_truthiness():
|
|
|
|
|
"""
|
|
|
|
|
Ensure that a cachefile with a synchronous cache file backend (the default)
|
|
|
|
|
is truthy.
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
spec = TestSpec(source=get_unique_image_file())
|
|
|
|
|
file = ImageCacheFile(spec)
|
|
|
|
|
assert_file_is_truthy(file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_async_backend_falsiness():
|
|
|
|
|
"""
|
|
|
|
|
Ensure that a cachefile with an asynchronous cache file backend is falsy.
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
spec = TestSpec(source=get_unique_image_file())
|
|
|
|
|
file = ImageCacheFile(spec, cachefile_backend=DummyAsyncCacheFileBackend())
|
|
|
|
|
assert_file_is_falsy(file)
|
|
|
|
|
|
|
|
|
|
|
2013-02-26 03:34:24 +00:00
|
|
|
@raises(TestSpec.MissingSource)
|
|
|
|
|
def test_no_source_error():
|
|
|
|
|
spec = TestSpec(source=None)
|
|
|
|
|
file = ImageCacheFile(spec)
|
|
|
|
|
file.generate()
|