vallettea / koala

Transpose your Excel calculations into python for better performances and scaling.
GNU General Public License v3.0
147 stars 59 forks source link

sp.set_value() not called properly on named cell #242

Open conradbez opened 4 years ago

conradbez commented 4 years ago
class Test_NamedRanges(unittest.TestCase):

    def setUp(self):
        self.sp = Spreadsheet("./tests/files/NamedRanges.xlsx", ignore_sheets = ['IHS'])
        sys.setrecursionlimit(10000)

    def test_before_set_value(self):
        self.assertTrue(self.sp.cell_evaluate('INPUT') == 1 and self.sp.cell_evaluate('Sheet1!A1') == 1 and self.sp.cell_evaluate('RESULT') == 187)

    # @unittest.skip('This test fails.')
    def test_after_set_value(self):
        # test if changing a input (named cell) leads to change in result (named cell with formula)
        self.sp.cell_set_value('INPUT', 2025)
        self.assertTrue(self.sp.cell_evaluate('INPUT') == 2025 and self.sp.cell_evaluate('Sheet1!A1') == 2025 and self.sp.cell_evaluate('RESULT') == 2211)

        # want to test multiple values as sometimes it gets stuck after one
        self.sp.cell_set_value('INPUT', 26)
        self.assertTrue(self.sp.cell_evaluate('INPUT') == 26 and self.sp.cell_evaluate('Sheet1!A1') == 2026 and self.sp.cell_evaluate('RESULT') == 212)

Updated the test and fails on second execute. The cell.set_value() is not called correctly and needs a clause to check if cell is in sp.named_ranges

This is my first issue submit so let me know if anything is wrong.