2020-03-22 03:14:02 +08:00
|
|
|
from django.core.checks.caches import E001, check_default_cache_is_configured
|
2015-09-02 20:20:46 +08:00
|
|
|
from django.test import SimpleTestCase
|
|
|
|
from django.test.utils import override_settings
|
|
|
|
|
|
|
|
|
|
|
|
class CheckCacheSettingsAppDirsTest(SimpleTestCase):
|
|
|
|
VALID_CACHES_CONFIGURATION = {
|
|
|
|
'default': {
|
|
|
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
INVALID_CACHES_CONFIGURATION = {
|
|
|
|
'other': {
|
|
|
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
@override_settings(CACHES=VALID_CACHES_CONFIGURATION)
|
|
|
|
def test_default_cache_included(self):
|
|
|
|
"""
|
|
|
|
Don't error if 'default' is present in CACHES setting.
|
|
|
|
"""
|
2020-03-22 03:14:02 +08:00
|
|
|
self.assertEqual(check_default_cache_is_configured(None), [])
|
2015-09-02 20:20:46 +08:00
|
|
|
|
|
|
|
@override_settings(CACHES=INVALID_CACHES_CONFIGURATION)
|
|
|
|
def test_default_cache_not_included(self):
|
|
|
|
"""
|
|
|
|
Error if 'default' not present in CACHES setting.
|
|
|
|
"""
|
2020-03-22 03:14:02 +08:00
|
|
|
self.assertEqual(check_default_cache_is_configured(None), [E001])
|