1 # -*- coding: utf-8 -*-
2 # This file is part of django-ssify, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See README.md for more information.
5 from __future__ import unicode_literals
8 from django.test import TestCase
9 from django.test.utils import override_settings
10 from tests.tests_utils import split_ssi
13 class ArgsTestCase(TestCase):
16 sorted(split_ssi(self.client.get('/args').content)),
17 sorted([b"<!--#set var='vff80027f1d552d08d46c8b603948d85c' value='2'-->",
18 b"<!--#set var='veeb5ec4364971b409c48e36bd1428d03' value='1'-->",
19 b"<!--#set var='v05a1f9ec205c5aa84197f6b326c518a2' value='0'-->",
20 b"<!--#echo var='v05a1f9ec205c5aa84197f6b326c518a2' encoding='none'-->",
24 def test_args_included(self):
26 self.client.get('/args/3').content.strip(),
27 b"<!--#echo var='v05a1f9ec205c5aa84197f6b326c518a2' encoding='none'-->"
30 def test_include_args(self):
32 sorted(split_ssi(self.client.get('/include_args').content)),
33 sorted([b"<!--#set var='vf6aba0780227af845107c046f336cc8a' value='3'-->",
34 b"<!--#set var='vff80027f1d552d08d46c8b603948d85c' value='2'-->",
35 b"<!--#set var='veeb5ec4364971b409c48e36bd1428d03' value='1'-->",
36 b"<!--#set var='v05a1f9ec205c5aa84197f6b326c518a2' value='0'-->",
37 b"<!--#include file='/args/${vf6aba0780227af845107c046f336cc8a}'-->",
41 # Test a second time, this time from cache.
43 sorted(split_ssi(self.client.get('/include_args').content)),
44 sorted([b"<!--#set var='vf6aba0780227af845107c046f336cc8a' value='3'-->",
45 b"<!--#set var='vff80027f1d552d08d46c8b603948d85c' value='2'-->",
46 b"<!--#set var='veeb5ec4364971b409c48e36bd1428d03' value='1'-->",
47 b"<!--#set var='v05a1f9ec205c5aa84197f6b326c518a2' value='0'-->",
48 b"<!--#include file='/args/${vf6aba0780227af845107c046f336cc8a}'-->",
52 @override_settings(SSIFY_DEBUG=True)
53 def test_debug_render_include_args(self):
55 """Renders the complete view using the DebugSsiMiddleware."""
56 response = self.client.get('/include_args')
57 if hasattr(response, 'render') and callable(response.render):
60 response.content.strip(),