Beispiel #1
0
 def test_clear_values_deletes_cells_with_empty_formula(self):
     ws = Worksheet()
     ws[1, 2].formula = ''
     ws[1, 2].value = "hello!"
     ws[1, 2].formatted_value = "Guten Tag!"
     ws.clear_values()
     self.assertFalse((1, 2) in ws)
 def test_clear_values_deletes_cells_with_empty_formula(self):
     ws = Worksheet()
     ws[1, 2].formula = ''
     ws[1, 2].value = "hello!"
     ws[1, 2].formatted_value = "Guten Tag!"
     ws.clear_values()
     self.assertFalse((1, 2) in ws)
Beispiel #3
0
    def test_clear_values_clears_values_and_formatted_values_and_errors(self):
        ws = Worksheet()
        ws[1, 2].formula = "=1"
        ws[1, 2].python_formula = "2"
        ws[1, 2].value = "hello!"
        ws[1, 2].formatted_value = "Guten Tag!"
        ws[1, 2].error = "Goodness Gracious!"

        ws[2, 2].python_formula = "1 + 1"

        ws.clear_values()

        self.assertEquals(ws[1, 2].formula, "=1")
        self.assertEquals(ws[1, 2].python_formula, "2")
        self.assertEquals(ws[1, 2].value, undefined)
        self.assertEquals(ws[1, 2].formatted_value, u'')
        self.assertEquals(ws[1, 2].error, None)

        self.assertEquals(ws[2, 2].python_formula, '1 + 1')
    def test_clear_values_clears_values_and_formatted_values_and_errors(self):
        ws = Worksheet()
        ws[1, 2].formula = "=1"
        ws[1, 2].python_formula = "2"
        ws[1, 2].value = "hello!"
        ws[1, 2].formatted_value = "Guten Tag!"
        ws[1, 2].error = "Goodness Gracious!"

        ws[2, 2].python_formula = "1 + 1"

        ws.clear_values()

        self.assertEquals(ws[1, 2].formula, "=1")
        self.assertEquals(ws[1, 2].python_formula, "2")
        self.assertEquals(ws[1, 2].value, undefined)
        self.assertEquals(ws[1, 2].formatted_value, u'')
        self.assertEquals(ws[1, 2].error, None)

        self.assertEquals(ws[2, 2].python_formula, '1 + 1')
    def test_calculate_clears_previous_worksheet_cell_values_before_executing_usercode(
        self, mock_execute_usercode
    ):
        calls_list = []
        worksheet = Worksheet()
        worksheet.clear_values = Mock()

        worksheet.clear_values.side_effect = lambda *args : calls_list.append('clear values')
        mock_execute_usercode.side_effect  = lambda *args : calls_list.append('execute usercode')

        calculate(worksheet, sentinel.usercode, sentinel.private_key)

        self.assertEquals(calls_list, ['clear values', 'execute usercode'])
Beispiel #6
0
    def test_calculate_clears_previous_worksheet_cell_values_before_executing_usercode(
            self, mock_execute_usercode):
        calls_list = []
        worksheet = Worksheet()
        worksheet.clear_values = Mock()

        worksheet.clear_values.side_effect = lambda *args: calls_list.append(
            'clear values')
        mock_execute_usercode.side_effect = lambda *args: calls_list.append(
            'execute usercode')

        calculate(worksheet, sentinel.usercode, sentinel.private_key)

        self.assertEquals(calls_list, ['clear values', 'execute usercode'])