Ejemplo n.º 1
0
def test_formless_plugin_in_lcfg(rf):
    two_thirds = int(LayoutCellGeneralInfoForm.CELL_FULL_WIDTH * 2 / 3)
    with plugin_override():
        with override_current_theme_class(None):
            theme = get_current_theme(get_default_shop())

            cell = LayoutCell(theme, "inject")
            assert cell.instantiate_plugin()
            lcfg = LayoutCellFormGroup(data={
                "general-cell_width":
                "%d" % two_thirds,
                "general-cell_align":
                "pull-right",
                "general-cell_extra_classes":
                "newClass",
            },
                                       layout_cell=cell,
                                       theme=theme,
                                       request=apply_request_middleware(
                                           rf.get("/")))

            assert "plugin" not in lcfg.forms
            assert lcfg.is_valid()
            lcfg.save()
            assert cell.extra_classes == "newClass"
            assert cell.sizes[
                "md"] == two_thirds  # Something got saved even if the plugin doesn't need config
Ejemplo n.º 2
0
def test_missing_plugin_render():
    plugin_id = printable_gibberish()
    cell = LayoutCell(FauxTheme, plugin_identifier=plugin_id)
    assert not cell.plugin_class
    assert not cell.instantiate_plugin()
    assert ("%s?" % plugin_id) in cell.render(
        None)  # Should render a "whut?" comment
Ejemplo n.º 3
0
def test_pluginless_lcfg():
    with plugin_override():
        with override_current_theme_class(None):
            theme = get_current_theme(get_default_shop())
            cell = LayoutCell(theme, None)
            assert not cell.instantiate_plugin()
            lcfg = LayoutCellFormGroup(layout_cell=cell, theme=theme)
            assert "plugin" not in lcfg.forms
Ejemplo n.º 4
0
def test_pluginless_lcfg(rf):
    with plugin_override():
        with override_current_theme_class(None):
            theme = get_current_theme(get_default_shop())
            cell = LayoutCell(theme, None)
            assert not cell.instantiate_plugin()
            lcfg = LayoutCellFormGroup(layout_cell=cell, theme=theme, request=apply_request_middleware(rf.get("/")))
            assert "plugin" not in lcfg.forms
Ejemplo n.º 5
0
def test_pluginless_lcfg():
    with plugin_override():
        with override_current_theme_class(None):
            request = get_request(edit=False)
            theme = get_current_theme(request)
            cell = LayoutCell(theme, None)
            assert not cell.instantiate_plugin()
            lcfg = LayoutCellFormGroup(layout_cell=cell, theme=theme)
            assert "plugin" not in lcfg.forms
Ejemplo n.º 6
0
def test_pluginless_lcfg():
    with plugin_override():
        with override_current_theme_class(None):
            request = get_request(edit=False)
            theme = get_current_theme(request)
            cell = LayoutCell(theme, None)
            assert not cell.instantiate_plugin()
            lcfg = LayoutCellFormGroup(layout_cell=cell, theme=theme)
            assert "plugin" not in lcfg.forms
Ejemplo n.º 7
0
def test_formless_plugin_in_lcfg():
    two_thirds = int(LayoutCellGeneralInfoForm.CELL_FULL_WIDTH * 2 / 3)
    with plugin_override():
        cell = LayoutCell("inject")
        assert cell.instantiate_plugin()
        lcfg = LayoutCellFormGroup(data={"general-cell_width": "%d" % two_thirds}, layout_cell=cell)
        assert "plugin" not in lcfg.forms
        assert lcfg.is_valid()
        lcfg.save()
        assert cell.sizes["md"] == two_thirds  # Something got saved even if the plugin doesn't need config
Ejemplo n.º 8
0
def test_formless_plugin_in_lcfg():
    two_thirds = int(LayoutCellGeneralInfoForm.CELL_FULL_WIDTH * 2 / 3)
    with plugin_override():
        cell = LayoutCell("inject")
        assert cell.instantiate_plugin()
        lcfg = LayoutCellFormGroup(
            data={"general-cell_width": "%d" % two_thirds}, layout_cell=cell)
        assert "plugin" not in lcfg.forms
        assert lcfg.is_valid()
        lcfg.save()
        assert cell.sizes[
            "md"] == two_thirds  # Something got saved even if the plugin doesn't need config
Ejemplo n.º 9
0
def test_formless_plugin_in_lcfg():
    two_thirds = int(LayoutCellGeneralInfoForm.CELL_FULL_WIDTH * 2 / 3)
    with plugin_override():
        with override_current_theme_class(None):
            request = get_request(edit=False)
            theme = get_current_theme(request)

            cell = LayoutCell(theme, "inject")
            assert cell.instantiate_plugin()
            lcfg = LayoutCellFormGroup(data={"general-cell_width": "%d" % two_thirds, "general-cell_align": "pull-right"}, layout_cell=cell, theme=theme)

            assert "plugin" not in lcfg.forms
            assert lcfg.is_valid()
            lcfg.save()
            assert cell.sizes["md"] == two_thirds  # Something got saved even if the plugin doesn't need config
Ejemplo n.º 10
0
def test_formless_plugin_in_lcfg():
    two_thirds = int(LayoutCellGeneralInfoForm.CELL_FULL_WIDTH * 2 / 3)
    with plugin_override():
        with override_current_theme_class(None):
            request = get_request(edit=False)
            theme = get_current_theme(request)

            cell = LayoutCell(theme, "inject")
            assert cell.instantiate_plugin()
            lcfg = LayoutCellFormGroup(data={"general-cell_width": "%d" % two_thirds}, layout_cell=cell, theme=theme)

            assert "plugin" not in lcfg.forms
            assert lcfg.is_valid()
            lcfg.save()
            assert cell.sizes["md"] == two_thirds  # Something got saved even if the plugin doesn't need config
Ejemplo n.º 11
0
def test_formless_plugin_in_lcfg(rf):
    two_thirds = int(LayoutCellGeneralInfoForm.CELL_FULL_WIDTH * 2 / 3)
    with plugin_override():
        with override_current_theme_class(None):
            theme = get_current_theme(get_default_shop())

            cell = LayoutCell(theme, "inject")
            assert cell.instantiate_plugin()
            lcfg = LayoutCellFormGroup(
                data={
                    "general-cell_width": "%d" % two_thirds,
                    "general-cell_align": "pull-right",
                    "general-cell_extra_classes" : "newClass",
                },
                layout_cell=cell,
                theme=theme,
                request=apply_request_middleware(rf.get("/"))
            )

            assert "plugin" not in lcfg.forms
            assert lcfg.is_valid()
            lcfg.save()
            assert cell.extra_classes == "newClass"
            assert cell.sizes["md"] == two_thirds  # Something got saved even if the plugin doesn't need config
Ejemplo n.º 12
0
def test_null_cell_render():
    cell = LayoutCell(FauxTheme, None)
    assert not cell.plugin_class
    assert not cell.instantiate_plugin()
    assert not cell.render(None)  # Should render nothing whatsoever!
Ejemplo n.º 13
0
def test_missing_plugin_render():
    plugin_id = printable_gibberish()
    cell = LayoutCell(FauxTheme, plugin_identifier=plugin_id)
    assert not cell.plugin_class
    assert not cell.instantiate_plugin()
    assert ("%s?" % plugin_id) in cell.render(None)  # Should render a "whut?" comment
Ejemplo n.º 14
0
def test_null_cell_render():
    cell = LayoutCell(FauxTheme, None)
    assert not cell.plugin_class
    assert not cell.instantiate_plugin()
    assert not cell.render(None)  # Should render nothing whatsoever!
Ejemplo n.º 15
0
def test_pluginless_lcfg():
    with plugin_override():
        cell = LayoutCell(None)
        assert not cell.instantiate_plugin()
        lcfg = LayoutCellFormGroup(layout_cell=cell)
        assert "plugin" not in lcfg.forms
Ejemplo n.º 16
0
def test_pluginless_lcfg():
    with plugin_override():
        cell = LayoutCell(None)
        assert not cell.instantiate_plugin()
        lcfg = LayoutCellFormGroup(layout_cell=cell)
        assert "plugin" not in lcfg.forms