コード例 #1
0
    def test_sort_descending(self, key, selection, res_key, res):
        """Tests sort_descending method"""

        self.grid.actions.change_grid_shape((10, 3, 2))

        data = {
            (0, 0, 0): "1",
            (1, 0, 0): "3",
            (2, 0, 0): "45",
            (9, 0, 0): "33",
            (2, 1, 0): "'Test'",
            (5, 1, 0): "3.2",
            (6, 2, 0): "1j",
            (3, 0, 1): "1",
        }

        for __key in data:
            self.grid.code_array[__key] = data[__key]

        selection.grid_select(self.grid)

        try:
            self.grid.actions.sort_descending(key)
            assert self.grid.code_array(res_key) == res

            # Test equality of code_array after undo and subsequent redo
            unredo_test(self.grid)

        except TypeError:
            assert res == 'fail'
コード例 #2
0
ファイル: test_grid_actions.py プロジェクト: 01-/pyspread
    def test_sort_descending(self, key, selection, res_key, res):
        """Tests sort_descending method"""

        self.grid.actions.change_grid_shape((10, 3, 2))

        data = {
            (0, 0, 0): "1",
            (1, 0, 0): "3",
            (2, 0, 0): "45",
            (9, 0, 0): "33",
            (2, 1, 0): "'Test'",
            (5, 1, 0): "3.2",
            (6, 2, 0): "1j",
            (3, 0, 1): "1",
        }

        for __key in data:
            self.grid.code_array[__key] = data[__key]

        selection.grid_select(self.grid)

        try:
            self.grid.actions.sort_descending(key)
            assert self.grid.code_array(res_key) == res

            # Test equality of code_array after undo and subsequent redo
            unredo_test(self.grid)

        except TypeError:
            assert res == 'fail'
コード例 #3
0
    def test_paste(self, tl_cell, data, test_key, test_val):
        """Tests paste into self.grid"""

        basic_setup_test(self.grid, self.grid.actions.paste, test_key,
                         test_val, tl_cell, data)

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #4
0
ファイル: test_grid_actions.py プロジェクト: 01-/pyspread
    def test_paste(self, tl_cell, data, test_key, test_val):
        """Tests paste into self.grid"""

        basic_setup_test(self.grid, self.grid.actions.paste, test_key,
                         test_val, tl_cell, data)

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #5
0
ファイル: test_grid_actions.py プロジェクト: 01-/pyspread
    def test_delete_cols(self, col, no_cols, test_key, test_val):
        """Tests deletion action for columns"""

        basic_setup_test(self.grid, self.grid.actions.delete_cols, test_key,
                         test_val, col, no_cols=no_cols)

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #6
0
ファイル: test_grid_actions.py プロジェクト: 01-/pyspread
    def test_delete_tabs(self, tab, no_tabs, test_key, test_val):
        """Tests deletion action for tabs"""

        basic_setup_test(self.grid, self.grid.actions.delete_tabs, test_key,
                         test_val, tab, no_tabs=no_tabs)

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #7
0
ファイル: test_grid_actions.py プロジェクト: 01-/pyspread
    def test_insert_rows(self, row, no_rows, test_key, test_val):
        """Tests insertion action for rows"""

        basic_setup_test(self.grid, self.grid.actions.insert_rows, test_key,
                         test_val, row, no_rows=no_rows)

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #8
0
ファイル: test_grid_actions.py プロジェクト: 01-/pyspread
    def test_set_col_width(self, col, tab, width):
        self.grid.current_table = tab
        self.grid.actions.set_col_width(col, width)
        col_widths = self.grid.code_array.col_widths
        assert col_widths[col, tab] == width

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #9
0
    def test_set_col_width(self, col, tab, width):
        self.grid.current_table = tab
        self.grid.actions.set_col_width(col, width)
        col_widths = self.grid.code_array.col_widths
        assert col_widths[col, tab] == width

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #10
0
ファイル: test_grid_actions.py プロジェクト: 01-/pyspread
    def test_set_row_height(self, row, tab, height):
        self.grid.current_table = tab
        self.grid.actions.set_row_height(row, height)
        row_heights = self.grid.code_array.row_heights
        assert row_heights[row, tab] == height

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #11
0
    def test_set_row_height(self, row, tab, height):
        self.grid.current_table = tab
        self.grid.actions.set_row_height(row, height)
        row_heights = self.grid.code_array.row_heights
        assert row_heights[row, tab] == height

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #12
0
    def test_delete_tabs(self, tab, no_tabs, test_key, test_val):
        """Tests deletion action for tabs"""

        basic_setup_test(self.grid,
                         self.grid.actions.delete_tabs,
                         test_key,
                         test_val,
                         tab,
                         no_tabs=no_tabs)

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #13
0
    def test_delete_cols(self, col, no_cols, test_key, test_val):
        """Tests deletion action for columns"""

        basic_setup_test(self.grid,
                         self.grid.actions.delete_cols,
                         test_key,
                         test_val,
                         col,
                         no_cols=no_cols)

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #14
0
    def test_insert_rows(self, row, no_rows, test_key, test_val):
        """Tests insertion action for rows"""

        basic_setup_test(self.grid,
                         self.grid.actions.insert_rows,
                         test_key,
                         test_val,
                         row,
                         no_rows=no_rows)

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #15
0
    def test_change_grid_shape(self, shape):
        """Tests action for changing the self.grid shape"""

        self.grid.actions.clear()

        self.grid.actions.change_grid_shape(shape)

        res_shape = self.grid.code_array.shape
        assert res_shape == shape

        br_key = tuple(dim - 1 for dim in shape)
        assert self.grid.code_array(br_key) is None

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #16
0
ファイル: test_grid_actions.py プロジェクト: 01-/pyspread
    def test_change_grid_shape(self, shape):
        """Tests action for changing the self.grid shape"""

        self.grid.actions.clear()

        self.grid.actions.change_grid_shape(shape)

        res_shape = self.grid.code_array.shape
        assert res_shape == shape

        br_key = tuple(dim - 1 for dim in shape)
        assert self.grid.code_array(br_key) is None

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #17
0
    def test_quote_selection(self):
        """Tests for quote_selection"""

        self.grid.code_array[(1, 0, 0)] = "Q1"
        self.grid.code_array[(2, 0, 0)] = 'u"NQ1"'

        self.grid.actions.select_cell(1, 0)
        self.grid.actions.select_cell(2, 0, add_to_selected=True)

        self.grid.actions.quote_selection()

        assert self.grid.code_array((1, 0, 0)) == 'u"Q1"'
        assert self.grid.code_array((2, 0, 0)) == 'u"NQ1"'

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #18
0
ファイル: test_grid_actions.py プロジェクト: 01-/pyspread
    def test_quote_selection(self):
        """Tests for quote_selection"""

        self.grid.code_array[(1, 0, 0)] = "Q1"
        self.grid.code_array[(2, 0, 0)] = 'u"NQ1"'

        self.grid.actions.select_cell(1, 0)
        self.grid.actions.select_cell(2, 0, add_to_selected=True)

        self.grid.actions.quote_selection()

        assert self.grid.code_array((1, 0, 0)) == 'u"Q1"'
        assert self.grid.code_array((2, 0, 0)) == 'u"NQ1"'

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #19
0
    def test_delete_selection(self):
        """Tests for delete_selection"""

        self.grid.code_array[(0, 0, 0)] = "Test"
        self.grid.code_array[(0, 0, 1)] = "Not deleted"

        self.grid.actions.select_cell(0, 0)
        self.grid.actions.delete_selection()

        assert self.grid.code_array[(0, 0, 0)] is None
        assert self.grid.code_array((0, 0, 1)) == "Not deleted"

        # Make sure that the result cache is empty
        assert not self.grid.code_array.result_cache

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #20
0
ファイル: test_grid_actions.py プロジェクト: 01-/pyspread
    def test_delete_selection(self):
        """Tests for delete_selection"""

        self.grid.code_array[(0, 0, 0)] = "Test"
        self.grid.code_array[(0, 0, 1)] = "Not deleted"

        self.grid.actions.select_cell(0, 0)
        self.grid.actions.delete_selection()

        assert self.grid.code_array[(0, 0, 0)] is None
        assert self.grid.code_array((0, 0, 1)) == "Not deleted"

        # Make sure that the result cache is empty
        assert not self.grid.code_array.result_cache

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #21
0
    def test_replace_cells(self, key, sorted_row_idxs, res_key, res):
        """Tests replace_cells method"""

        self.grid.actions.change_grid_shape((10, 3, 2))

        data = {
            (0, 0, 0): "1",
            (1, 0, 0): "3",
            (2, 0, 0): "45",
            (9, 0, 0): "33",
            (3, 1, 0): "'Test'",
            (5, 1, 0): "3.2",
            (6, 2, 0): "1j",
            (3, 0, 1): "1",
        }
        for __key in data:
            self.grid.code_array[__key] = data[__key]

        self.grid.actions.replace_cells(key, sorted_row_idxs)

        assert self.grid.code_array(res_key) == res

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)
コード例 #22
0
ファイル: test_grid_actions.py プロジェクト: 01-/pyspread
    def test_replace_cells(self, key, sorted_row_idxs, res_key, res):
        """Tests replace_cells method"""

        self.grid.actions.change_grid_shape((10, 3, 2))

        data = {
            (0, 0, 0): "1",
            (1, 0, 0): "3",
            (2, 0, 0): "45",
            (9, 0, 0): "33",
            (3, 1, 0): "'Test'",
            (5, 1, 0): "3.2",
            (6, 2, 0): "1j",
            (3, 0, 1): "1",
        }
        for __key in data:
            self.grid.code_array[__key] = data[__key]

        self.grid.actions.replace_cells(key, sorted_row_idxs)

        assert self.grid.code_array(res_key) == res

        # Test equality of code_array after undo and subsequent redo
        unredo_test(self.grid)