Revert "ziafazal/WL-328: Multi-Site Comprehensive Theming"

This reverts commit 954dae584a.
This commit is contained in:
Jesse Zoldak
2016-03-16 11:19:36 -04:00
parent b91f940af7
commit f891d27cbb
67 changed files with 411 additions and 2187 deletions

View File

@@ -6,33 +6,21 @@ from django.test import TestCase
from path import path # pylint: disable=no-name-in-module
from django.contrib import staticfiles
from paver.easy import call_task
from openedx.core.djangoapps.theming.test_util import with_comprehensive_theme
from openedx.core.lib.tempdir import mkdtemp_clean, mksym_link
from openedx.core.lib.tempdir import mkdtemp_clean
class TestComprehensiveTheming(TestCase):
"""Test comprehensive theming."""
@classmethod
def setUpClass(cls):
compile_sass('lms')
super(TestComprehensiveTheming, cls).setUpClass()
def setUp(self):
super(TestComprehensiveTheming, self).setUp()
# Clear the internal staticfiles caches, to get test isolation.
staticfiles.finders.get_finder.cache_clear()
@with_comprehensive_theme('red-theme')
@with_comprehensive_theme(settings.REPO_ROOT / 'themes/red-theme')
def test_red_footer(self):
"""
Tests templates from theme are rendered if available.
`red-theme` has header.html and footer.html so this test
asserts presence of the content from header.html and footer.html
"""
resp = self.client.get('/')
self.assertEqual(resp.status_code, 200)
# This string comes from footer.html
@@ -46,16 +34,12 @@ class TestComprehensiveTheming(TestCase):
# of test.
# Make a temp directory as a theme.
themes_dir = path(mkdtemp_clean())
tmp_theme = "temp_theme"
template_dir = themes_dir / tmp_theme / "lms/templates"
tmp_theme = path(mkdtemp_clean())
template_dir = tmp_theme / "lms/templates"
template_dir.makedirs()
with open(template_dir / "footer.html", "w") as footer:
footer.write("<footer>TEMPORARY THEME</footer>")
dest_path = path(settings.COMPREHENSIVE_THEME_DIR) / tmp_theme
mksym_link(themes_dir / tmp_theme, dest_path)
@with_comprehensive_theme(tmp_theme)
def do_the_test(self):
"""A function to do the work so we can use the decorator."""
@@ -66,18 +50,16 @@ class TestComprehensiveTheming(TestCase):
do_the_test(self)
def test_theme_adjusts_staticfiles_search_path(self):
"""
Tests theme directories are added to staticfiles search path.
"""
# Test that a theme adds itself to the staticfiles search path.
before_finders = list(settings.STATICFILES_FINDERS)
before_dirs = list(settings.STATICFILES_DIRS)
@with_comprehensive_theme('red-theme')
@with_comprehensive_theme(settings.REPO_ROOT / 'themes/red-theme')
def do_the_test(self):
"""A function to do the work so we can use the decorator."""
self.assertEqual(list(settings.STATICFILES_FINDERS), before_finders)
self.assertIn(settings.REPO_ROOT / 'themes/red-theme/lms/static', settings.STATICFILES_DIRS)
self.assertEqual(settings.STATICFILES_DIRS, before_dirs)
self.assertEqual(settings.STATICFILES_DIRS[0], settings.REPO_ROOT / 'themes/red-theme/lms/static')
self.assertEqual(settings.STATICFILES_DIRS[1:], before_dirs)
do_the_test(self)
@@ -85,9 +67,9 @@ class TestComprehensiveTheming(TestCase):
result = staticfiles.finders.find('images/logo.png')
self.assertEqual(result, settings.REPO_ROOT / 'lms/static/images/logo.png')
@with_comprehensive_theme('red-theme')
@with_comprehensive_theme(settings.REPO_ROOT / 'themes/red-theme')
def test_overridden_logo_image(self):
result = staticfiles.finders.find('red-theme/lms/static/images/logo.png')
result = staticfiles.finders.find('images/logo.png')
self.assertEqual(result, settings.REPO_ROOT / 'themes/red-theme/lms/static/images/logo.png')
def test_default_favicon(self):
@@ -97,54 +79,10 @@ class TestComprehensiveTheming(TestCase):
result = staticfiles.finders.find('images/favicon.ico')
self.assertEqual(result, settings.REPO_ROOT / 'lms/static/images/favicon.ico')
@with_comprehensive_theme('red-theme')
def test_css(self):
"""
Test that static files finders are adjusted according to the applied comprehensive theme.
"""
result = staticfiles.finders.find('red-theme/lms/static/css/lms-main.css')
self.assertEqual(result, settings.REPO_ROOT / "themes/red-theme/lms/static/css/lms-main.css")
lms_main_css = ""
with open(result) as css_file:
lms_main_css += css_file.read()
self.assertIn("background:#fa0000", lms_main_css)
def test_default_css(self):
"""
Test default css is served if no theme is applied
"""
result = staticfiles.finders.find('css/lms-main.css')
self.assertEqual(result, settings.REPO_ROOT / "lms/static/css/lms-main.css")
lms_main_css = ""
with open(result) as css_file:
lms_main_css += css_file.read()
self.assertNotIn("background:#00fa00", lms_main_css)
@with_comprehensive_theme('red-theme')
@with_comprehensive_theme(settings.REPO_ROOT / 'themes/red-theme')
def test_overridden_favicon(self):
"""
Test comprehensive theme override on favicon image.
"""
result = staticfiles.finders.find('red-theme/lms/static/images/favicon.ico')
result = staticfiles.finders.find('images/favicon.ico')
self.assertEqual(result, settings.REPO_ROOT / 'themes/red-theme/lms/static/images/favicon.ico')
def compile_sass(system):
"""
Process xmodule assets and compile sass files.
:param system - 'lms' or 'cms', specified the system to compile sass for.
"""
# Compile system sass files
call_task(
'pavelib.assets.update_assets',
args=(
system,
"--themes_dir={themes_dir}".format(themes_dir=settings.COMPREHENSIVE_THEME_DIR),
"--themes=red-theme",
"--settings=test"),
)

View File

@@ -9,7 +9,7 @@ from django.conf import settings
from django.test import TestCase
from django.test.utils import override_settings
from openedx.core.djangoapps.theming.test_util import with_comprehensive_theme
from openedx.core.djangoapps.theming.test_util import with_is_edx_domain
@attr('shard_1')
@@ -37,7 +37,7 @@ class TestFooter(TestCase):
"youtube": "https://www.youtube.com/"
}
@with_comprehensive_theme("edx.org")
@with_is_edx_domain(True)
def test_edx_footer(self):
"""
Verify that the homepage, when accessed at edx.org, has the edX footer
@@ -46,6 +46,7 @@ class TestFooter(TestCase):
self.assertEqual(resp.status_code, 200)
self.assertContains(resp, 'footer-edx-v3')
@with_is_edx_domain(False)
def test_openedx_footer(self):
"""
Verify that the homepage, when accessed at something other than
@@ -55,7 +56,7 @@ class TestFooter(TestCase):
self.assertEqual(resp.status_code, 200)
self.assertContains(resp, 'footer-openedx')
@with_comprehensive_theme("edx.org")
@with_is_edx_domain(True)
@override_settings(
SOCIAL_MEDIA_FOOTER_NAMES=SOCIAL_MEDIA_NAMES,
SOCIAL_MEDIA_FOOTER_URLS=SOCIAL_MEDIA_URLS