Merge pull request #5036 from edx/sanchez/fix_django_header_tests

Sanchez/fix django header tests
This commit is contained in:
Stephen Sanchez
2014-09-02 10:44:16 -04:00
6 changed files with 89 additions and 20 deletions

View File

@@ -3,35 +3,35 @@ Tests related to the basic footer-switching based off SITE_NAME to ensure
edx.org uses an edx footer but other instances use an Open edX footer.
"""
from mock import patch
from django.test import TestCase
from django.test.utils import override_settings
class TestFooter(TestCase):
@override_settings(SITE_NAME="edx.org")
def test_edx_footer(self):
"""
Verify that the homepage, when accessed at edx.org, has the edX footer
"""
with patch.dict('django.conf.settings.FEATURES', {"IS_EDX_DOMAIN": True}):
resp = self.client.get('/')
self.assertEqual(resp.status_code, 200)
resp = self.client.get('/')
self.assertEqual(resp.status_code, 200)
# assert that footer template has been properly overridden on homepage
# test the top-level element class; which is less likely to change than copy.
self.assertContains(resp, 'edx-footer')
# assert that footer template has been properly overridden on homepage
# test the top-level element class; which is less likely to change than copy.
self.assertContains(resp, 'edx-footer')
@override_settings(SITE_NAME="example.com")
def test_openedx_footer(self):
"""
Verify that the homepage, when accessed at something other than
edx.org, has the Open edX footer
"""
with patch.dict('django.conf.settings.FEATURES', {"IS_EDX_DOMAIN": False}):
resp = self.client.get('/')
self.assertEqual(resp.status_code, 200)
resp = self.client.get('/')
self.assertEqual(resp.status_code, 200)
# assert that footer template has been properly overridden on homepage
# test the top-level element class; which is less likely to change than copy.
self.assertContains(resp, 'wrapper-footer')
# assert that footer template has been properly overridden on homepage
# test the top-level element class; which is less likely to change than copy.
self.assertContains(resp, 'wrapper-footer')

View File

@@ -367,6 +367,12 @@ TEMPLATE_CONTEXT_PROCESSORS = (
# Hack to get required link URLs to password reset templates
'edxmako.shortcuts.marketing_link_context_processor',
# Allows the open edX footer to be leveraged in Django Templates.
'edxmako.shortcuts.open_source_footer_context_processor',
# TODO: Used for header and footer feature flags. Remove as part of ECOM-136
'edxmako.shortcuts.header_footer_context_processor',
# Shoppingcart processor (detects if request.user has a cart)
'shoppingcart.context_processor.user_has_cart_context_processor',
)

View File

@@ -83,7 +83,7 @@
google_analytics_file = microsite.get_template_path('google_analytics.html')
if getattr(settings, 'SITE_NAME', '').endswith('edx.org') and not is_microsite():
if settings.FEATURES['IS_EDX_DOMAIN'] and not is_microsite():
if settings.FEATURES.get('ENABLE_NEW_EDX_FOOTER', False):
footer_file = microsite.get_template_path('edx_footer.html')
else:

View File

@@ -31,13 +31,24 @@
<body class="{% block bodyclass %}{% endblock %} lang_{{LANGUAGE_CODE}}">
<a class="nav-skip" href="{% block nav_skip %}#content{% endblock %}">{% trans "Skip to this view's content" %}</a>
{% include "navigation.html" %}
{% if ENABLE_NEW_EDX_HEADER %}
{% include "navigation.html" %}
{% else %}
{% include "original_navigation.html" %}
{% endif %}
<div class="content-wrapper" id="content">
{% block body %}{% endblock %}
{% block bodyextra %}{% endblock %}
</div>
{% include "edx_footer.html" %}
{% if IS_EDX_DOMAIN %}
{% if ENABLE_NEW_EDX_FOOTER %}
{% include "edx_footer.html" %}
{% else %}
{% include "original_edx_footer.html" %}
{% endif %}
{% else %}
{% include "footer.html" %}
{% endif %}
{% compressed_js 'application' %}
{% compressed_js 'module-js' %}