import pytest def test_check_table_header_raises_error(): from superx_budget.budget import ExcelRow, _check_table_header from superx_budget.exceptions import BudgetParserError row = ExcelRow(None, ["not", "the", "expected", "row", None, 0]) with pytest.raises(BudgetParserError): _check_table_header(row) def test_skip_empty_lines(): from superx_budget.budget import ExcelRow, _skip_empty_lines rows = [ ExcelRow(0, [""]), ExcelRow(1, ["one"]), ExcelRow(2, [None]), ExcelRow(3, [""]), ExcelRow(4, ["two"]), ExcelRow(5, [""]), ] result = _skip_empty_lines(rows) assert list(result) == [(1, ["one"]), (4, ["two"])] def test_parse_data_table(): from superx_budget.budget import ExcelRow, _parse_data_table rows = [ ExcelRow(2, list("ABCDEFGH")), ExcelRow(3, [None for i in range(8)]), ExcelRow(4, list("stuvwxyzX")), # one item more ] result = _parse_data_table(rows) first, last = list(result) assert first.row == 2 assert first.number == "A" assert first.rest == "H" assert last.row == 4 assert last.number == "s" assert last.rest == "z" def test_parse_budget_data(budget_example_sheet): from superx_budget.budget import parse_budget_data result = parse_budget_data(budget_example_sheet) first, last = result[0], result[-1] assert len(result) == 20 assert first.row == 3 assert first.number == 1 assert first.project_name == "Safeguard IV" assert first.rest == "=F3-G3" assert last.row == 61 def test_parse_budget_file(budget_example_file): from superx_budget.budget import parse_budget_file result = parse_budget_file(budget_example_file) first = result[0] assert len(result) == 20 assert first.row == 3 assert first.number == 1 assert first.project_name == "Safeguard IV" assert first.rest == "=F3-G3"