def with_comprehensive_theme(theme_dir): """ A decorator to run a test with a particular comprehensive theme. Arguments: theme_dir (str): the full path to the theme directory to use. This will likely use `settings.REPO_ROOT` to get the full path. """ # This decorator gets the settings changes needed for a theme, and applies # them using the override_settings and edxmako.paths.add_lookup context # managers. changes = comprehensive_theme_changes(theme_dir) def _decorator(func): # pylint: disable=missing-docstring @wraps(func) def _decorated(*args, **kwargs): # pylint: disable=missing-docstring with override_settings(COMPREHENSIVE_THEME_DIR=theme_dir, **changes['settings']): default_engine = Engine.get_default() dirs = default_engine.dirs[:] with edxmako.save_lookups(): for template_dir in changes['template_paths']: edxmako.paths.add_lookup('main', template_dir, prepend=True) dirs.insert(0, template_dir) with patch.object(default_engine, 'dirs', dirs): return func(*args, **kwargs) return _decorated return _decorator
def with_comprehensive_theme(theme_dir): """ A decorator to run a test with a particular comprehensive theme. Arguments: theme_dir (str): the full path to the theme directory to use. This will likely use `settings.REPO_ROOT` to get the full path. """ # This decorator gets the settings changes needed for a theme, and applies # them using the override_settings and edxmako.paths.add_lookup context # managers. changes = comprehensive_theme_changes(theme_dir) def _decorator(func): # pylint: disable=missing-docstring @wraps(func) def _decorated(*args, **kwargs): # pylint: disable=missing-docstring with override_settings(COMPREHENSIVE_THEME_DIR=theme_dir, **changes['settings']): default_engine = Engine.get_default() dirs = default_engine.dirs[:] with edxmako.save_lookups(): for template_dir in changes['template_paths']: edxmako.paths.add_lookup('main', template_dir, prepend=True) dirs.insert(0, template_dir) with patch.object(default_engine, 'dirs', dirs): return func(*args, **kwargs) return _decorated return _decorator
def with_edx_domain_context(is_edx_domain): """ A function to run a test as if request originated from edX domain or not. Arguments: is_edx_domain (bool): are we an edX domain or not? """ if 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['template_paths']: edxmako.paths.add_lookup('main', template_dir, prepend=True) yield else: yield
def with_edx_domain_context(is_edx_domain): """ A function to run a test as if request originated from edX domain or not. Arguments: is_edx_domain (bool): are we an edX domain or not? """ if 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['template_paths']: edxmako.paths.add_lookup('main', template_dir, prepend=True) yield else: yield