Normalized check framework test pattern.

This commit is contained in:
Adam Johnson 2020-03-21 19:14:02 +00:00 committed by GitHub
parent 2117b7c12e
commit ffde4d5da8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 159 deletions

View file

@ -1,4 +1,4 @@
from django.core.checks.caches import E001
from django.core.checks.caches import E001, check_default_cache_is_configured
from django.test import SimpleTestCase
from django.test.utils import override_settings
@ -15,21 +15,16 @@ class CheckCacheSettingsAppDirsTest(SimpleTestCase):
},
}
@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), [])
self.assertEqual(check_default_cache_is_configured(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])
self.assertEqual(check_default_cache_is_configured(None), [E001])