Beispiel #1
0
def test_rendering(edit, injectable, theme_class, global_type):
    request = get_request(edit)
    request.resolver_match = mock.Mock()
    request.resolver_match.app_name = "shuup"

    with override_current_theme_class(theme_class):
        with plugin_override():
            jeng = get_jinja2_engine()
            if global_type:
                template = jeng.get_template("global_complex.jinja")
            else:
                template = jeng.get_template("complex.jinja")
            view = FauxView()
            view.xtheme_injection = bool(injectable)
            output = template.render(context={
                "view": view,
                "request": request
            },
                                     request=request)

            # From now on we render placholders in views that
            # actually can be edited.
            if injectable and theme_class:
                assert "wider column" in output
                assert "less wide column" in output

            if edit and injectable and theme_class:
                assert "xt-ph-edit" in output
                assert "data-xt-placeholder-name" in output
                assert "data-xt-row" in output
                assert "data-xt-cell" in output
                assert "XthemeEditorConfig" in output
Beispiel #2
0
def test_rendering(edit, injectable, theme_class, global_type):
    request = get_request(edit)
    request.resolver_match = mock.Mock()
    request.resolver_match.app_name = "shuup"

    with override_current_theme_class(theme_class):
        with plugin_override():
            jeng = get_jinja2_engine()
            if global_type:
                template = jeng.get_template("global_complex.jinja")
            else:
                template = jeng.get_template("complex.jinja")
            view = FauxView()
            view.xtheme_injection = bool(injectable)
            output = template.render(context={
                "view": view,
                "request": request
            }, request=request)

            # From now on we render placholders in views that
            # actually can be edited.
            if injectable and theme_class:
                assert "wider column" in output
                assert "less wide column" in output

            if edit and injectable and theme_class:
                assert "xt-ph-edit" in output
                assert "data-xt-placeholder-name" in output
                assert "data-xt-row" in output
                assert "data-xt-cell" in output
                assert "XthemeEditorConfig" in output
Beispiel #3
0
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)
Beispiel #4
0
def test_rendering(edit, injectable, theme_class, global_type):
    request = get_request(edit)
    with override_current_theme_class(theme_class):
        with plugin_override():
            jeng = get_jinja2_engine()
            if global_type:
                template = jeng.get_template("global_complex.jinja")
            else:
                template = jeng.get_template("complex.jinja")
            view = FauxView()
            view.xtheme_injection = bool(injectable)
            output = template.render(context={
                "view": view,
            }, request=request)
            assert "wider column" in output
            assert "less wide column" in output
            if edit and injectable and theme_class:
                assert "xt-ph-edit" in output
                assert "data-xt-placeholder-name" in output
                assert "data-xt-row" in output
                assert "data-xt-cell" in output
                assert "XthemeEditorConfig" in output
Beispiel #5
0
def test_rendering(edit, injectable, theme_class, global_type):
    request = get_request(edit)
    with override_current_theme_class(theme_class):
        with plugin_override():
            jeng = get_jinja2_engine()
            if global_type:
                template = jeng.get_template("global_complex.jinja")
            else:
                template = jeng.get_template("complex.jinja")
            view = FauxView()
            view.xtheme_injection = bool(injectable)
            output = template.render(context={
                "view": view,
            }, request=request)
            assert "wider column" in output
            assert "less wide column" in output
            if edit and injectable and theme_class:
                assert "xt-ph-edit" in output
                assert "data-xt-placeholder-name" in output
                assert "data-xt-row" in output
                assert "data-xt-cell" in output
                assert "XthemeEditorConfig" in output