def test_layout_rendering_with_global_type(rf): request = get_request(edit=False) with override_current_theme_class(None): with plugin_override(): jeng = get_jinja2_engine() template = jeng.from_string("") (template, layout, gibberish, ctx) = get_test_template_bits(request) global_class = "xt-global-ph" result = six.text_type( render_placeholder(ctx, "test", layout, template.template.name, global_type=True)) assert global_class in result result = six.text_type( render_placeholder(ctx, "test", layout, template.template.name, global_type=False)) assert global_class not in result
def test_layout_rendering_with_global_type(rf): request = get_request(edit=False) with override_current_theme_class(None): with plugin_override(): jeng = get_jinja2_engine() template = jeng.from_string("") (template, layout, gibberish, ctx) = get_test_template_bits(request) global_class = "xt-global-ph" result = six.text_type(render_placeholder(ctx, "test", layout, template.template.name, global_type=True)) assert global_class in result result = six.text_type(render_placeholder(ctx, "test", layout, template.template.name, global_type=False)) assert global_class not in result
def test_render_custom_size_cell(rf): request = get_request(edit=False) with override_current_theme_class(None): with plugin_override(): with layout_override(): layout = Layout(FauxTheme, "test") gibberish = printable_gibberish() layout.begin_column({"md": None, "xs": None, "sm": None}) layout.add_plugin("text", {"text": "<p>%s</p>" % gibberish}) jeng = get_jinja2_engine() template = jeng.from_string("") template.template.name = "test" vars = { "view": FauxView(), "request": request } ctx = template.template.new_context(vars) result = six.text_type(render_placeholder(ctx, "test", layout, "test")) expect = """ <div class="placeholder-edit-wrap"> <div class="xt-ph" id="xt-ph-test"> <div class="row xt-ph-row"> <div class="xt-ph-cell"><p>%s</p></div> </div> </div> </div> """ % gibberish assert close_enough(result, expect)
def _render_placeholder(self, context, placeholder_name, layout, template_name, global_type): return render_placeholder( context, placeholder_name=placeholder_name, default_layout=layout, template_name=template_name, global_type=global_type, )
def test_layout_edit_render(): request = get_request(edit=True) with override_current_theme_class(None): with plugin_override(): (template, layout, gibberish, ctx) = get_test_template_bits(request) result = six.text_type(render_placeholder(ctx, "test", layout, "test")) # Look for evidence of editing: assert "xt-ph-edit" in result assert "data-xt-placeholder-name" in result assert "data-xt-row" in result assert "data-xt-cell" in result
def test_layout_rendering(rf): request = get_request(edit=False) with override_current_theme_class(None): with plugin_override(): (template, layout, gibberish, ctx) = get_test_template_bits(request) result = six.text_type(render_placeholder(ctx, "test", layout, "test")) expect = """ <div class="xt-ph" id="xt-ph-test"> <div class="row xt-ph-row"> <div class="col-md-12 hidden-xs xt-ph-cell"><p>%s</p></div> </div> </div> """ % gibberish assert close_enough(result, expect)