diff options
| author | Tom Christie <tom@tomchristie.com> | 2015-09-02 13:20:46 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-09-18 07:44:39 -0400 |
| commit | b02f08e02c34bcf19444c15b54c5f64ddd4c9ef2 (patch) | |
| tree | a5abe6749a8c1880c9117fddcef7741e9593888d /tests/check_framework/test_caches.py | |
| parent | f33b3ebd5302fe5821dd796156b0be66c5aebec9 (diff) | |
Fixed #25034 -- Converted caches ImproperlyConfigured error to a system check.
Diffstat (limited to 'tests/check_framework/test_caches.py')
| -rw-r--r-- | tests/check_framework/test_caches.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/check_framework/test_caches.py b/tests/check_framework/test_caches.py new file mode 100644 index 0000000000..ab16c6071c --- /dev/null +++ b/tests/check_framework/test_caches.py @@ -0,0 +1,35 @@ +from django.core.checks.caches import E001 +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', + }, + } + + @property + def func(self): + from django.core.checks.caches import check_default_cache_is_configured + return check_default_cache_is_configured + + @override_settings(CACHES=VALID_CACHES_CONFIGURATION) + def test_default_cache_included(self): + """ + Don't error if 'default' is present in CACHES setting. + """ + self.assertEqual(self.func(None), []) + + @override_settings(CACHES=INVALID_CACHES_CONFIGURATION) + def test_default_cache_not_included(self): + """ + Error if 'default' not present in CACHES setting. + """ + self.assertEqual(self.func(None), [E001]) |
