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
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
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
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
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
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
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
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
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
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
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!
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
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