Пример #1
0
    def test_render_theme_template(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        setup_themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            coolsrc = render_theme_template('cool', 'hello.html').strip()
            plainsrc = render_theme_template('plain', 'hello.html').strip()
            assert coolsrc == 'Hello from Cool Blue v2.'
            assert plainsrc == 'Hello from the application'
Пример #2
0
    def test_active_theme(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        setup_themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            appdata = render_template('active.html').strip()
            cooldata = render_theme_template('cool', 'active.html').strip()
            plaindata = render_theme_template('plain', 'active.html').strip()
            assert appdata == 'Application, Active theme: none'
            assert cooldata == 'Cool Blue v2, Active theme: cool'
            assert plaindata == 'Application, Active theme: plain'
Пример #3
0
    def test_theme_static(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        setup_themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            coolurl = static_file_url('cool', 'style.css')
            cooldata = render_theme_template('cool', 'static.html').strip()
            assert cooldata == 'Cool Blue v2, %s' % coolurl
Пример #4
0
def render(template, **context):
    theme = session.get('theme', app.config['DEFAULT_THEME'])
    return render_theme_template(theme, template, **context)