def test_layout_api(): l = Layout(FauxTheme, "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!
def test_layout_api(): l = Layout(FauxTheme, "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! assert l.move_row_to_index(0, 1) assert len(l) == 3 and list(map(len, l.rows)) == [0, 1, 2] assert l.move_row_to_index(2, 0) assert len(l) == 3 and list(map(len, l.rows)) == [2, 0, 1] assert not l.move_row_to_index(1, 100) assert len(l) == 3 and list(map(len, l.rows)) == [2, 0, 1] assert not l.move_row_to_index(1, -1) assert len(l) == 3 and list(map(len, l.rows)) == [2, 0, 1] cell = l.get_cell(0, 0) # top left to bottom right assert l.move_cell_to_position(0, 0, 1, 2) assert l.get_cell(1, 2) == cell assert len(l) == 3 and list(map(len, l.rows)) == [1, 0, 2] cell = l.get_cell(0, 0) # top left to middle assert l.move_cell_to_position(0, 0, 0, 1) assert l.get_cell(0, 0) == cell assert len(l) == 2 and list(map(len, l.rows)) == [1, 2] # invalid cell assert not l.move_cell_to_position(0, 100, 0, 1) # move to invalid cell assert not l.move_cell_to_position(0, 0, 100, 1)