def test_missing_plugin_render(): plugin_id = printable_gibberish() cell = LayoutCell(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_formless_plugin_in_lcfg(): with plugin_override(): cell = LayoutCell("inject") assert cell.instantiate_plugin() lcfg = LayoutCellFormGroup(data={"general-size_md": "8"}, layout_cell=cell) assert "plugin" not in lcfg.forms assert lcfg.is_valid() lcfg.save() assert cell.sizes["md"] == 8 # 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(): with plugin_override(): cell = LayoutCell("inject") assert cell.instantiate_plugin() lcfg = LayoutCellFormGroup(data={"general-size_md": "8"}, layout_cell=cell) assert "plugin" not in lcfg.forms assert lcfg.is_valid() lcfg.save() assert cell.sizes[ "md"] == 8 # 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_lcfg(): with plugin_override(): cell = LayoutCell("text", sizes={"md": 8}) lcfg = LayoutCellFormGroup(layout_cell=cell) assert "general" in lcfg.forms assert "plugin" in lcfg.forms assert not lcfg.is_valid() # Oh, we must've forgotten the text... lcfg = LayoutCellFormGroup(data={ "general-size_md": "8", "plugin-text": "Hello, world!" }, layout_cell=cell) assert lcfg.is_valid() # Let's see now! lcfg.save() assert cell.sizes["md"] == 8 assert cell.config["text"] == "Hello, world!"
def test_lcfg(): two_thirds = int(LayoutCellGeneralInfoForm.CELL_FULL_WIDTH * 2 / 3) with plugin_override(): cell = LayoutCell("text", sizes={"md": two_thirds, "sm": two_thirds}) lcfg = LayoutCellFormGroup(layout_cell=cell) assert "general" in lcfg.forms assert "plugin" in lcfg.forms assert not lcfg.is_valid() # Oh, we must've forgotten the text... lcfg = LayoutCellFormGroup(data={ "general-cell_width": "%d" % two_thirds, "plugin-text": "Hello, world!" }, layout_cell=cell) assert lcfg.is_valid() # Let's see now! lcfg.save() assert cell.sizes["md"] == two_thirds assert cell.config["text"] == "Hello, world!"
def test_null_cell_render(): cell = LayoutCell(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(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
def test_plugin_naming(): with plugin_override(): cell = LayoutCell(TextPlugin.identifier) assert cell.plugin_name == TextPlugin.name