def test_default_theme_render_macro_jade(): webconfig.init_theme() ctx = {"macro_arg": "testvalue"} with app.test_request_context(): html = webconfig.theme.render_macro("test.j2.jade", "testmacro", ctx) assert "macro_arg: testvalue" in html assert "macro_kwarg: default" in html
def test_default_theme_render_template_jade(): webconfig.init_theme() ctx = {"ctx_variable": "testvalue"} with app.test_request_context(): html = webconfig.theme.render_template("test.j2.jade", ctx) assert "<html>" in html assert "testvalue" in html
def test_default_theme_render_template_jade_without_extension_fail(): webconfig.init_theme() ctx = {} with raises(TemplateNotFound) as excinfo: with app.test_request_context(): webconfig.theme.render_template("test", ctx) assert "invalid" in excinfo.value.message
def test_login_no_referer(req): from core.webconfig import init_theme, add_template_globals from core import webconfig init_theme() webconfig.theme.make_jinja_loader() with app.test_request_context(): assert login.login(req) == 200 assert req.session["return_after_login"] is False
def test_default_theme_render_macro_jade_without_extension_fail(): webconfig.init_theme() ctx = {} with raises(TemplateNotFound) as excinfo: with app.test_request_context(): webconfig.theme.render_macro("test", "testmacro", ctx) assert "invalid" in excinfo.value.message
def test_login_login_from_edit(req): from core.webconfig import init_theme, add_template_globals from core import webconfig init_theme() webconfig.theme.make_jinja_loader() req.headers["Referer"] = "http://localhost/edit/edit_content?id=604993" req.headers["Host"] = "localhost" with app.test_request_context(): assert login.login(req) == 200 assert req.session["return_after_login"] == "http://localhost/edit?id=604993"
def test_login_from_other(req): from core.webconfig import init_theme, add_template_globals from core import webconfig init_theme() webconfig.theme.make_jinja_loader() ref = "http://localhost/justatest" req.headers["Host"] = "localhost" req.headers["Referer"] = ref with app.test_request_context(): assert login.login(req) == 200 assert req.session["return_after_login"] == ref
def test_pwdchange(pwdchange_patch, req, session, collections): from core.webconfig import init_theme, add_template_globals from core import webconfig init_theme() webconfig.theme.make_jinja_loader() add_template_globals() req.form["ChangeSubmit"] = True req.form["user"] = LOGIN_NAME req.form["password_old"] = PASSWORD req.form["password_new1"] = NEW_PASSWORD req.form["password_new2"] = NEW_PASSWORD_REPEATED with app.test_request_context(): assert login.pwdchange(req) == pwdchange_patch
def test_default_theme_dir(): webconfig.init_theme() jinja_loader = webconfig.theme.make_jinja_loader() dirpath = jinja_loader.searchpath[0] assert os.path.isdir(dirpath) assert dirpath.endswith("templates")
def test_show_node_big_video_url(video, req): from core import webconfig webconfig.init_theme() video.has_data_access = lambda *a, **k: True html = video.show_node_big(req) assert u"/file/{}/{}".format(video.id, TEST_VIDEO_NAME) in html