def test_evaluate_entire_row_column(excel_compiler): value = excel_compiler.evaluate(AddressRange('Sheet1!A:A')) expected = excel_compiler.evaluate(AddressRange('Sheet1!A1:A18')) assert value == expected assert len(value) == 18 assert not list_like(value[0]) value = excel_compiler.evaluate(AddressRange('Sheet1!1:1')) expected = excel_compiler.evaluate(AddressRange('Sheet1!A1:D1')) assert value == expected assert len(value) == 4 assert not list_like(value[0]) value = excel_compiler.evaluate(AddressRange('Sheet1!A:B')) expected = excel_compiler.evaluate(AddressRange('Sheet1!A1:B18')) assert value == expected assert len(value) == 18 assert len(value[0]) == 2 value = excel_compiler.evaluate(AddressRange('Sheet1!1:2')) expected = excel_compiler.evaluate(AddressRange('Sheet1!A1:D2')) assert value == expected assert len(value) == 2 assert len(value[0]) == 4 # now from the text based file excel_compiler._to_text() text_excel_compiler = ExcelCompiler._from_text(excel_compiler.filename) value = text_excel_compiler.evaluate(AddressRange('Sheet1!A:A')) expected = text_excel_compiler.evaluate(AddressRange('Sheet1!A1:A18')) assert value == expected assert len(value) == 18 assert not list_like(value[0]) value = text_excel_compiler.evaluate(AddressRange('Sheet1!1:1')) expected = text_excel_compiler.evaluate(AddressRange('Sheet1!A1:D1')) assert value == expected assert len(value) == 4 assert not list_like(value[0]) value = text_excel_compiler.evaluate(AddressRange('Sheet1!A:B')) expected = text_excel_compiler.evaluate(AddressRange('Sheet1!A1:B18')) assert len(value) == 18 assert len(value[0]) == 2 assert value == expected value = text_excel_compiler.evaluate(AddressRange('Sheet1!1:2')) expected = text_excel_compiler.evaluate(AddressRange('Sheet1!A1:D2')) assert value == expected assert len(value) == 2 assert len(value[0]) == 4
def test_trim_cells(excel_compiler): input_addrs = ['trim-range!D5'] output_addrs = ['trim-range!B2'] old_value = excel_compiler.evaluate(output_addrs[0]) excel_compiler.trim_graph(input_addrs, output_addrs) excel_compiler._to_text(is_json=True) new_value = ExcelCompiler._from_text( excel_compiler.filename, is_json=True).evaluate(output_addrs[0]) assert old_value == new_value
def test_trim_cells_range(excel_compiler): input_addrs = [AddressRange('trim-range!D4:E4')] output_addrs = ['trim-range!B2'] old_value = excel_compiler.evaluate(output_addrs[0]) excel_compiler.trim_graph(input_addrs, output_addrs) excel_compiler._to_text() excel_compiler = ExcelCompiler._from_text(excel_compiler.filename) assert old_value == excel_compiler.evaluate(output_addrs[0]) excel_compiler.set_value(input_addrs[0], [5, 6], set_as_range=True) assert old_value - 1 == excel_compiler.evaluate(output_addrs[0]) excel_compiler.set_value(input_addrs[0], [4, 6]) assert old_value - 2 == excel_compiler.evaluate(output_addrs[0]) excel_compiler.set_value(tuple(next(input_addrs[0].rows)), [5, 6]) assert old_value - 1 == excel_compiler.evaluate(output_addrs[0])
def test_evaluate_empty(excel_compiler): assert 0 == excel_compiler.evaluate('Empty!B1') excel_compiler.recalculate() assert 0 == excel_compiler.evaluate('Empty!B1') input_addrs = ['Empty!C1', 'Empty!B2'] output_addrs = ['Empty!B1', 'Empty!B2'] excel_compiler.trim_graph(input_addrs, output_addrs) excel_compiler._to_text(is_json=True) text_excel_compiler = ExcelCompiler._from_text(excel_compiler.filename, is_json=True) assert [0, None] == text_excel_compiler.evaluate(output_addrs) text_excel_compiler.set_value(input_addrs[0], 10) assert [10, None] == text_excel_compiler.evaluate(output_addrs) text_excel_compiler.set_value(input_addrs[1], 20) assert [10, 20] == text_excel_compiler.evaluate(output_addrs)
def test_evaluate_empty(excel_compiler): assert 0 == excel_compiler.evaluate('Empty!B1') excel_compiler.recalculate() assert 0 == excel_compiler.evaluate('Empty!B1') input_addrs = ['Empty!C1', 'Empty!B2'] output_addrs = ['Empty!B1', 'Empty!B2'] excel_compiler.trim_graph(input_addrs, output_addrs) excel_compiler._to_text(is_json=True) text_excel_compiler = ExcelCompiler._from_text( excel_compiler.filename, is_json=True) assert [0, None] == text_excel_compiler.evaluate(output_addrs) text_excel_compiler.set_value(input_addrs[0], 10) assert [10, None] == text_excel_compiler.evaluate(output_addrs) text_excel_compiler.set_value(input_addrs[1], 20) assert [10, 20] == text_excel_compiler.evaluate(output_addrs)
def test_evaluate_entire_row_column(excel_compiler): value = excel_compiler.evaluate(AddressRange('Sheet1!A:B')) expected = excel_compiler.evaluate(AddressRange('Sheet1!A1:B18')) assert value == expected value = excel_compiler.evaluate(AddressRange('Sheet1!1:2')) expected = excel_compiler.evaluate(AddressRange('Sheet1!A1:D2')) assert value == expected # now from the text based file excel_compiler._to_text() text_excel_compiler = ExcelCompiler._from_text(excel_compiler.filename) value = text_excel_compiler.evaluate(AddressRange('Sheet1!A:B')) expected = text_excel_compiler.evaluate(AddressRange('Sheet1!A1:B18')) assert value == expected value = text_excel_compiler.evaluate(AddressRange('Sheet1!1:2')) expected = text_excel_compiler.evaluate(AddressRange('Sheet1!A1:D2')) assert value == expected