55 lines
2.3 KiB
Python
55 lines
2.3 KiB
Python
from __future__ import unicode_literals
|
|
from django.conf import settings
|
|
from django.test import SimpleTestCase
|
|
|
|
|
|
class TemplatesTestCase(SimpleTestCase):
|
|
def setUp(self):
|
|
super().setUp()
|
|
self.response_from_root_view = self.client.get('/')
|
|
|
|
def test_template_usage(self):
|
|
response = self.response_from_root_view
|
|
self.assertTemplateUsed(response, 'dav_base/base.html')
|
|
self.assertTemplateUsed(response, 'project_name.html')
|
|
|
|
def test_html_head(self):
|
|
response = self.response_from_root_view
|
|
|
|
static_url = settings.STATIC_URL
|
|
|
|
html_needles = (
|
|
# favicon
|
|
'<link type="image/x-icon" href="{static_url}dav_base/img/dav-favicon.ico" rel="shortcut icon" />',
|
|
# bootstrap css
|
|
'<link type="text/css" href="{static_url}dav_base/bootstrap/css/bootstrap.min.css" rel="stylesheet" />',
|
|
# css file for jquery.dataTables.js
|
|
'<link type="text/css" href="{static_url}dav_base/css/dataTables.bootstrap.min.css" rel="stylesheet" />',
|
|
# local css file
|
|
'<link type="text/css" href="{static_url}dav_base/css/local.css" rel="stylesheet" />',
|
|
# jquery.js file
|
|
'<script type="text/javascript" src="{static_url}dav_base/js/jquery.min.js"></script>',
|
|
# jquery.dataTables.js file
|
|
'<script type="text/javascript" src="{static_url}dav_base/js/jquery.dataTables.min.js"></script>',
|
|
# bootstrap js file
|
|
'<script type="text/javascript" src="{static_url}dav_base/bootstrap/js/bootstrap.min.js"></script>',
|
|
)
|
|
|
|
content = response.content.decode('utf-8')
|
|
for needle in html_needles:
|
|
needle = needle.format(static_url=static_url)
|
|
self.assertInHTML(needle, content)
|
|
|
|
def test_page_footer(self):
|
|
response = self.response_from_root_view
|
|
|
|
html = """
|
|
<div id="page-footer">
|
|
<div class="signum"><a href="mailto:tourenportal@alpenverein-karlsruhe.de">tourenportal@alpenverein-karlsruhe.de</a></div>
|
|
<a href="https://alpenverein-karlsruhe.de" target="_blank">© Sektion Karlsruhe im Deutschen Alpenverein (DAV) e.V.</a>  • 
|
|
<a href="https://alpenverein-karlsruhe.de/impressum">Impressum</a>
|
|
</div>
|
|
"""
|
|
|
|
self.assertInHTML(html, response.content.decode('utf-8'))
|