コード例 #1
0
ファイル: test_layout.py プロジェクト: teserak/shoop
def test_layout_serialization():
    with plugin_override():
        l = Layout("test")
        l.begin_column({"md": 8})
        l.add_plugin("text", {"text": "yes"})
        serialized = l.serialize()
        expected = {
            'name': "test",
            'rows': [
                {
                    'cells': [
                        {'config': {'text': 'yes'}, 'plugin': 'text', 'sizes': {"md": 8}}
                    ]
                }
            ]
        }
        assert serialized == expected
        assert Layout.unserialize(serialized).serialize() == expected
コード例 #2
0
ファイル: test_layout.py プロジェクト: cuberskulk/shoop
def test_layout_serialization():
    with plugin_override():
        l = Layout("test")
        l.begin_column({"md": 8})
        l.add_plugin("text", {"text": "yes"})
        serialized = l.serialize()
        expected = {
            'name': "test",
            'rows': [
                {
                    'cells': [
                        {'config': {'text': 'yes'}, 'plugin': 'text', 'sizes': {"md": 8}}
                    ]
                }
            ]
        }
        assert serialized == expected
        assert Layout.unserialize(serialized).serialize() == expected
コード例 #3
0
ファイル: test_layout.py プロジェクト: cuberskulk/shoop
def test_layout_api():
    l = Layout("test")
    l.begin_column({"md": 8})
    px0y0 = l.add_plugin("text", {"text": "yes"})
    l.begin_column({"md": 4})
    px1y0 = l.add_plugin("text", {"text": "no"})
    assert len(l) == 1
    assert len(l.rows[0]) == 2
    assert not l.delete_cell(x=0, y=1)  # nonexistent row
    assert l.get_cell(0, 0) == px0y0
    assert l.get_cell(1, 0) == px1y0
    assert not l.get_cell(2, 0)
    assert not l.get_cell(0, 1)
    l.begin_row()
    assert len(l) == 2
    assert len(l.rows[1]) == 0
    l.begin_column()
    assert len(l.rows[1]) == 1
    assert l.delete_cell(x=0, y=1)  # existent cell
    assert not l.delete_cell(x=0, y=1)  # cell existent no more
    assert l.delete_row(1)  # existent row
    assert len(l) == 1
    assert not l.delete_row(1)  # nonexistent row
    l.insert_row(0).add_cell()  # insert a cellful row in first place
    assert len(l) == 2 and list(map(len, l.rows)) == [1, 2]
    l.insert_row(1)  # insert an empty row in second place
    assert len(l) == 3 and list(map(len, l.rows)) == [1, 0, 2]
    assert not l.insert_row(-1)  # that's silly!
コード例 #4
0
ファイル: test_layout.py プロジェクト: teserak/shoop
def test_layout_api():
    l = Layout("test")
    l.begin_column({"md": 8})
    px0y0 = l.add_plugin("text", {"text": "yes"})
    l.begin_column({"md": 4})
    px1y0 = l.add_plugin("text", {"text": "no"})
    assert len(l) == 1
    assert len(l.rows[0]) == 2
    assert not l.delete_cell(x=0, y=1)  # nonexistent row
    assert l.get_cell(0, 0) == px0y0
    assert l.get_cell(1, 0) == px1y0
    assert not l.get_cell(2, 0)
    assert not l.get_cell(0, 1)
    l.begin_row()
    assert len(l) == 2
    assert len(l.rows[1]) == 0
    l.begin_column()
    assert len(l.rows[1]) == 1
    assert l.delete_cell(x=0, y=1)  # existent cell
    assert not l.delete_cell(x=0, y=1)  # cell existent no more
    assert l.delete_row(1)  # existent row
    assert len(l) == 1
    assert not l.delete_row(1)  # nonexistent row
    l.insert_row(0).add_cell()  # insert a cellful row in first place
    assert len(l) == 2 and list(map(len, l.rows)) == [1, 2]
    l.insert_row(1)  # insert an empty row in second place
    assert len(l) == 3 and list(map(len, l.rows)) == [1, 0, 2]
    assert not l.insert_row(-1)  # that's silly!