user-selectable light and dark themes
cookies, template rendering with different CSS files via default or request param or cookie, etc.
This commit is contained in:
3
tests/instance/pages/mdash-or-triple-dash.md
Normal file
3
tests/instance/pages/mdash-or-triple-dash.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Test page
|
||||
|
||||
word --- word
|
||||
@@ -1,5 +1,7 @@
|
||||
"""Unit test helper methods."""
|
||||
from incorporealcms.pages import generate_parent_navs, is_file_path_actually_dir_path, resolve_page_file
|
||||
from werkzeug.http import dump_cookie
|
||||
|
||||
from incorporealcms.pages import generate_parent_navs, is_file_path_actually_dir_path, render, resolve_page_file
|
||||
|
||||
|
||||
def test_resolve_page_file_dir_to_index():
|
||||
@@ -74,3 +76,25 @@ def test_is_file_path_actually_dir_path_nonsense_dir_is_no(app):
|
||||
"""Test that a directory request is a directory request even if the dir doesn't exist."""
|
||||
with app.app_context():
|
||||
assert not is_file_path_actually_dir_path('/antphnathpnthapnthsnthax/')
|
||||
|
||||
|
||||
def test_render_with_user_dark_theme(app):
|
||||
"""Test that a request with the dark theme selected renders the dark theme."""
|
||||
cookie = dump_cookie("user-style", 'dark')
|
||||
with app.test_request_context(headers={'COOKIE': cookie}):
|
||||
assert b'dark.css' in render('base.html').data
|
||||
assert b'light.css' not in render('base.html').data
|
||||
|
||||
|
||||
def test_render_with_user_light_theme(app):
|
||||
"""Test that a request with the light theme selected renders the light theme."""
|
||||
with app.test_request_context():
|
||||
assert b'light.css' in render('base.html').data
|
||||
assert b'dark.css' not in render('base.html').data
|
||||
|
||||
|
||||
def test_render_with_no_user_theme(app):
|
||||
"""Test that a request with no theme set renders the light theme."""
|
||||
with app.test_request_context():
|
||||
assert b'light.css' in render('base.html').data
|
||||
assert b'dark.css' not in render('base.html').data
|
||||
|
||||
Reference in New Issue
Block a user