1
1
from django .core .cache import caches
2
2
from django .core .files .uploadedfile import SimpleUploadedFile
3
- from django .template import Context , Template
3
+ from django .template import Context , Template , TemplateSyntaxError
4
4
from django .test import TestCase
5
5
from django .test .utils import override_settings
6
6
@@ -15,6 +15,18 @@ def setUp(self):
15
15
"{{ site_config.site_name }}"
16
16
"{{ site_config.file.url }}"
17
17
)
18
+ self .template_invalid_app = Template (
19
+ "{% load solo_tags %}"
20
+ '{% get_solo "invalid_app.SiteConfiguration" as site_config %}'
21
+ "{{ site_config.site_name }}"
22
+ "{{ site_config.file.url }}"
23
+ )
24
+ self .template_invalid_model = Template (
25
+ "{% load solo_tags %}"
26
+ '{% get_solo "tests.InvalidModel" as site_config %}'
27
+ "{{ site_config.site_name }}"
28
+ "{{ site_config.file.url }}"
29
+ )
18
30
self .cache = caches ["default" ]
19
31
self .cache_key = SiteConfiguration .get_cache_key ()
20
32
self .cache .clear ()
@@ -95,6 +107,14 @@ def test_cache_prefix_overriding(self):
95
107
prefix = key .partition (":" )[0 ]
96
108
self .assertEqual (prefix , "other" )
97
109
110
+ def test_template_tag_invalid_app_name (self ):
111
+ with self .assertRaises (TemplateSyntaxError ):
112
+ self .template_invalid_app .render (Context ())
113
+
114
+ def test_template_invalid_model_name (self ):
115
+ with self .assertRaises (TemplateSyntaxError ):
116
+ self .template_invalid_model .render (Context ())
117
+
98
118
99
119
class SingletonWithExplicitIdTest (TestCase ):
100
120
def setUp (self ):
0 commit comments