Commit 06e38e1c by Zia Fazal

added branding to 404 and 500 error pages

changes based on feedback

renamed a definition and added test coverage

fixed broken tests
parent 87d9a079
......@@ -125,6 +125,10 @@ else:
return is_request_in_themed_site()
%></%def>
<%def name="get_tech_support_email_address()"><%
return get_value('email_from_address', settings.TECH_SUPPORT_EMAIL)
%></%def>
<%def name="show_language_selector()"><%
return settings.FEATURES.get('SHOW_LANGUAGE_SELECTOR', False)
%></%def>
import mimetypes
"""
Tests for static templates
"""
from django.test import TestCase
from django.conf import settings
from django.core.urlresolvers import reverse
......@@ -24,3 +25,71 @@ class MarketingSiteViewTests(TestCase):
Test the about view
"""
self._test_view('about', 'text/html')
def test_404(self):
"""
Test the 404 view.
"""
url = reverse('static_template_view.views.render_404')
resp = self.client.get(url)
self.assertEqual(resp.status_code, 200)
self.assertEqual(resp['Content-Type'], 'text/html')
resp = self.client.get(url)
self.assertContains(resp, settings.TECH_SUPPORT_EMAIL)
def test_500(self):
"""
Test the 500 view.
"""
url = reverse('static_template_view.views.render_500')
resp = self.client.get(url)
self.assertEqual(resp.status_code, 500)
self.assertEqual(resp['Content-Type'], 'text/html; charset=utf-8')
# check response with branding
resp = self.client.get(url)
self.assertContains(
resp,
'There has been a 500 error on the <em>{platform_name}</em> servers'.format(
platform_name=settings.PLATFORM_NAME
),
status_code=500
)
self.assertContains(resp, settings.TECH_SUPPORT_EMAIL, status_code=500)
def test_404_microsites(self):
"""
Test the 404 view as if called in a microsite.
"""
url = reverse('static_template_view.views.render_404')
resp = self.client.get(url)
self.assertEqual(resp.status_code, 200)
self.assertEqual(resp['Content-Type'], 'text/html')
# check response with branding
resp = self.client.get(url, HTTP_HOST=settings.MICROSITE_TEST_HOSTNAME)
self.assertContains(resp, settings.MICROSITE_CONFIGURATION['test_microsite']['email_from_address'])
def test_500_microsites(self):
"""
Test the 500 view as if called in a microsite.
"""
url = reverse('static_template_view.views.render_500')
resp = self.client.get(url)
self.assertEqual(resp.status_code, 500)
self.assertEqual(resp['Content-Type'], 'text/html; charset=utf-8')
# check response with branding
resp = self.client.get(url, HTTP_HOST=settings.MICROSITE_TEST_HOSTNAME)
self.assertContains(
resp,
'There has been a 500 error on the <em>{platform_name}</em> servers'.format(
platform_name=settings.MICROSITE_CONFIGURATION['test_microsite']['platform_name']
),
status_code=500
)
self.assertContains(
resp,
settings.MICROSITE_CONFIGURATION['test_microsite']['email_from_address'],
status_code=500
)
<%namespace name='static' file='../static_content.html'/>
<%! from django.utils.translation import ugettext as _ %>
<%inherit file="../main.html" />
......@@ -6,5 +7,6 @@
<section class="outside-app">
<h1>${_("Page not found")}</h1>
<p>${_('The page that you were looking for was not found. Go back to the {link_start}homepage{link_end} or let us know about any pages that may have been moved at {email}.').format(
link_start='<a href="/">', link_end='</a>', email='<a href="mailto:{email}">{email}</a>'.format(email=settings.TECH_SUPPORT_EMAIL))}</p>
link_start='<a href="/">', link_end='</a>', email='<a href="mailto:{email}">{email}</a>'.format(email=static.get_tech_support_email_address())
)}</p>
</section>
<%namespace name='static' file='../static_content.html'/>
<%! from django.utils.translation import ugettext as _ %>
<%inherit file="../main.html" />
<section class="outside-app">
<h1>
${_(u"There has been a 500 error on the {platform_name} servers").format(
platform_name=u"<em>{platform_name}</em>".format(platform_name=settings.PLATFORM_NAME)
platform_name=u"<em>{platform_name}</em>".format(platform_name=static.get_platform_name())
)}
</h1>
<p>
${_(u'Please wait a few seconds and then reload the page. If the problem persists, please email us at {email}.').format(
email=u'<a href="mailto:{email}">{email}</a>'.format(
email=settings.TECH_SUPPORT_EMAIL
email=static.get_tech_support_email_address()
)
)}
</p>
......
......@@ -84,7 +84,7 @@ def with_edx_domain_context(is_edx_domain):
changes = comprehensive_theme_changes(EDX_THEME_DIR)
with override_settings(COMPREHENSIVE_THEME_DIR=EDX_THEME_DIR, **changes['settings']):
with edxmako.save_lookups():
for template_dir in changes['mako_paths']:
for template_dir in changes['template_paths']:
edxmako.paths.add_lookup('main', template_dir, prepend=True)
yield
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment