Fix footer test failures
This commit is contained in:
@@ -6,6 +6,7 @@ from django.test import TestCase
|
||||
from path import path # pylint: disable=no-name-in-module
|
||||
from django.contrib import staticfiles
|
||||
|
||||
import edxmako
|
||||
from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme
|
||||
from openedx.core.lib.tempdir import mkdtemp_clean, create_symlink, delete_symlink
|
||||
|
||||
@@ -49,6 +50,8 @@ class TestComprehensiveTheming(TestCase):
|
||||
dest_path = path(settings.COMPREHENSIVE_THEME_DIRS[0]) / tmp_theme
|
||||
create_symlink(themes_dir / tmp_theme, dest_path)
|
||||
|
||||
edxmako.paths.add_lookup('main', themes_dir, prepend=True)
|
||||
|
||||
@with_comprehensive_theme(tmp_theme)
|
||||
def do_the_test(self):
|
||||
"""A function to do the work so we can use the decorator."""
|
||||
|
||||
@@ -106,6 +106,8 @@ def get_template_path_with_theme(relative_path):
|
||||
Returns:
|
||||
(str): template path in current site's theme
|
||||
"""
|
||||
relative_path = os.path.normpath(relative_path)
|
||||
|
||||
theme = get_current_theme()
|
||||
|
||||
if not theme:
|
||||
|
||||
@@ -25,8 +25,7 @@ class TestComprehensiveThemeLMS(TestCase):
|
||||
# Clear the internal staticfiles caches, to get test isolation.
|
||||
staticfiles.finders.get_finder.cache_clear()
|
||||
|
||||
@override_settings(COMPREHENSIVE_THEME_DIRS=[settings.TEST_THEME.dirname()])
|
||||
@with_comprehensive_theme(settings.TEST_THEME.basename())
|
||||
@with_comprehensive_theme("test-theme")
|
||||
def test_footer(self):
|
||||
"""
|
||||
Test that theme footer is used instead of default footer.
|
||||
@@ -36,8 +35,7 @@ class TestComprehensiveThemeLMS(TestCase):
|
||||
# This string comes from header.html of test-theme
|
||||
self.assertContains(resp, "This is a footer for test-theme.")
|
||||
|
||||
@override_settings(COMPREHENSIVE_THEME_DIRS=[settings.TEST_THEME.dirname()])
|
||||
@with_comprehensive_theme(settings.TEST_THEME.basename())
|
||||
@with_comprehensive_theme("test-theme")
|
||||
def test_logo_image(self):
|
||||
"""
|
||||
Test that theme logo is used instead of default logo.
|
||||
@@ -61,8 +59,7 @@ class TestComprehensiveThemeCMS(TestCase):
|
||||
# Clear the internal staticfiles caches, to get test isolation.
|
||||
staticfiles.finders.get_finder.cache_clear()
|
||||
|
||||
@override_settings(COMPREHENSIVE_THEME_DIRS=[settings.TEST_THEME.dirname()])
|
||||
@with_comprehensive_theme(settings.TEST_THEME.basename())
|
||||
@with_comprehensive_theme("test-theme")
|
||||
def test_template_override(self):
|
||||
"""
|
||||
Test that theme templates are used instead of default templates.
|
||||
|
||||
@@ -32,9 +32,6 @@ def with_comprehensive_theme(theme_dir_name):
|
||||
site, __ = Site.objects.get_or_create(domain=domain, name=domain)
|
||||
site_theme, __ = SiteTheme.objects.get_or_create(site=site, theme_dir_name=theme_dir_name)
|
||||
|
||||
for _dir in settings.COMPREHENSIVE_THEME_DIRS:
|
||||
edxmako.paths.add_lookup('main', _dir, prepend=True)
|
||||
|
||||
with patch('openedx.core.djangoapps.theming.helpers.get_current_site_theme',
|
||||
return_value=site_theme):
|
||||
with patch('openedx.core.djangoapps.theming.helpers.get_current_site', return_value=site):
|
||||
@@ -57,9 +54,6 @@ def with_comprehensive_theme_context(theme=None):
|
||||
site, __ = Site.objects.get_or_create(domain=domain, name=theme)
|
||||
site_theme, __ = SiteTheme.objects.get_or_create(site=site, theme_dir_name=theme)
|
||||
|
||||
for _dir in settings.COMPREHENSIVE_THEME_DIRS:
|
||||
edxmako.paths.add_lookup('main', _dir, prepend=True)
|
||||
|
||||
with patch('openedx.core.djangoapps.theming.helpers.get_current_site_theme',
|
||||
return_value=site_theme):
|
||||
with patch('openedx.core.djangoapps.theming.helpers.get_current_site', return_value=site):
|
||||
|
||||
Reference in New Issue
Block a user