Unit Tests for CachedLoader

This commit is contained in:
Adnan Umer 2017-04-17 15:53:56 +05:00
parent 8634634b1c
commit a21ed181fe
4 changed files with 36 additions and 2 deletions

View File

@ -1,5 +1,6 @@
from .test_routes import *
from .test_tenants import *
from .template_loader import *
from .test_cache import *
from .test_log import *
from .test_routes import *
from .test_tenants import *
from .test_utils import *

View File

@ -0,0 +1 @@
from .test_cached_template_loader import CachedLoaderTests

View File

@ -0,0 +1 @@
Hello! (Django templates)

View File

@ -0,0 +1,31 @@
import os
from django.template.loader import get_template
from django.test import SimpleTestCase, override_settings
@override_settings(
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(os.path.dirname(__file__), "templates")
],
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
],
'loaders': [
('tenant_schemas.template_loaders.CachedLoader', (
'tenant_schemas.template_loaders.FilesystemLoader',
'django.template.loaders.filesystem.Loader'
))
]
},
}
]
)
class CachedLoaderTests(SimpleTestCase):
def test_get_template(self):
template = get_template("hello.html")
self.assertEqual(template.render(), "Hello! (Django templates)\n")