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
@@ -16,6 +16,18 @@ def setUp(self):
16
16
"{{ site_config.site_name }}"
17
17
"{{ site_config.file.url }}"
18
18
)
19
+ self .template_invalid_app = Template (
20
+ "{% load solo_tags %}"
21
+ '{% get_solo "invalid_app.SiteConfiguration" as site_config %}'
22
+ "{{ site_config.site_name }}"
23
+ "{{ site_config.file.url }}"
24
+ )
25
+ self .template_invalid_model = Template (
26
+ "{% load solo_tags %}"
27
+ '{% get_solo "tests.InvalidModel" as site_config %}'
28
+ "{{ site_config.site_name }}"
29
+ "{{ site_config.file.url }}"
30
+ )
19
31
self .cache = caches ["default" ]
20
32
self .cache_key = SiteConfiguration .get_cache_key ()
21
33
self .cache .clear ()
@@ -96,6 +108,14 @@ def test_cache_prefix_overriding(self):
96
108
prefix = key .partition (":" )[0 ]
97
109
self .assertEqual (prefix , "other" )
98
110
111
+ def test_template_tag_invalid_app_name (self ):
112
+ with self .assertRaises (TemplateSyntaxError ):
113
+ self .template_invalid_app .render (Context ())
114
+
115
+ def test_template_invalid_model_name (self ):
116
+ with self .assertRaises (TemplateSyntaxError ):
117
+ self .template_invalid_model .render (Context ())
118
+
99
119
100
120
class SingletonWithExplicitIdTest (TestCase ):
101
121
def setUp (self ):
0 commit comments