1 from django.test import Client, TestCase
2 from django.test.utils import override_settings
5 class SsifyTestCase(TestCase):
11 self.client.get('/number_zero').content,
12 "<!--#set var='ve023a08d2c2075118e25b5f4339438dc' value='0'-->"
13 "<!--#echo var='ve023a08d2c2075118e25b5f4339438dc' "
17 def test_single_quote(self):
19 self.client.get('/quote/3').content.strip(),
20 """Explicit is better than implicit.
21 Line 3 of <!--#echo var='va50d914691ecf9b421c680d93ba1263e' encoding='none'-->
22 <!--#if expr='${vddc386e120ab274a980ab67384391a1a}'-->Odd number of characters.
23 <!--#else-->Even number of characters.
27 def test_random_quote(self):
29 self.client.get('/').content.strip(),
30 "<!--#set var='vda0df841702ea993b36d101460264364' value='4'-->"
31 "<!--#set var='va50d914691ecf9b421c680d93ba1263e' value='22'-->"
32 "<!--#set var='vafe010f2e683908fee32c48d01bb2650' value=''-->"
33 "\n\n<!--#include file='/random_quote'-->"
36 # Do it again, this time from cache.
38 self.client.get('/').content.strip(),
39 "<!--#set var='vda0df841702ea993b36d101460264364' value='4'-->"
40 "<!--#set var='va50d914691ecf9b421c680d93ba1263e' value='22'-->"
41 "<!--#set var='vafe010f2e683908fee32c48d01bb2650' value=''-->"
42 "\n\n<!--#include file='/random_quote'-->"
45 self.client.get('/random_quote').content.strip(),
47 "file='/quote/${vda0df841702ea993b36d101460264364}'-->"
50 @override_settings(SSIFY_DEBUG=True)
51 def test_debug_render_random_quote(self):
52 """Renders the complete view using the DebugSsiMiddleware."""
53 response = self.client.get('/')
54 if hasattr(response, 'render') and callable(response.render):
57 response.content.strip(),
58 """Simple is better than complex.
60 Even number of characters."""