예제 #1
0
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
예제 #2
0
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
예제 #3
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
예제 #4
0
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
예제 #5
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
예제 #6
0
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!"
예제 #7
0
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!"
예제 #8
0
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!
예제 #9
0
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
예제 #10
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
예제 #11
0
def test_plugin_naming():
    with plugin_override():
        cell = LayoutCell(TextPlugin.identifier)
        assert cell.plugin_name == TextPlugin.name
예제 #12
0
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!
예제 #13
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