Browse Source

fixed the tests for the latest changes

main
Holger Frey 2 months ago
parent
commit
fe85d9d279
  1. 4
      superx_budget/budget.py
  2. 7
      tests/test_budget_parser.py
  3. 2
      tests/test_overview.py

4
superx_budget/budget.py

@ -16,7 +16,7 @@ EXPECTED_TABLE_HEADERS = [
"Rest", "Rest",
] ]
EXCEL_LINES_TO_IGNORE = {"stand:", "stand"} EXCEL_LINES_TO_IGNORE = {"stand"}
NUM_EXPECTED_HEADERS = len(EXPECTED_TABLE_HEADERS) NUM_EXPECTED_HEADERS = len(EXPECTED_TABLE_HEADERS)
@ -56,7 +56,7 @@ def _skip_some_lines(rows):
continue continue
if isinstance(first_cell, str): if isinstance(first_cell, str):
value = first_cell.strip().lower() value = first_cell.strip().lower()
if value in EXCEL_LINES_TO_IGNORE: if any(value.startswith(item) for item in EXCEL_LINES_TO_IGNORE):
continue continue
yield xl_row yield xl_row

7
tests/test_budget_parser.py

@ -21,6 +21,7 @@ def test_skip_empty_lines():
ExcelRow(3, [""]), ExcelRow(3, [""]),
ExcelRow(4, ["two"]), ExcelRow(4, ["two"]),
ExcelRow(5, [""]), ExcelRow(5, [""]),
ExcelRow(5, ["sTanD:"]),
] ]
result = _skip_some_lines(rows) result = _skip_some_lines(rows)
@ -54,12 +55,12 @@ def test_parse_budget_data(budget_example_sheet):
result = parse_budget_data(budget_example_sheet) result = parse_budget_data(budget_example_sheet)
first, last = result[0], result[-1] first, last = result[0], result[-1]
assert len(result) == 20 assert len(result) == 19 # the line starting with "Stand" is filtered out
assert first.row == 3 assert first.row == 3
assert first.number == 1 assert first.number == 1
assert first.project_name == "Safeguard IV" assert first.project_name == "Safeguard IV"
assert first.rest == "=F3-G3" assert first.rest == "=F3-G3"
assert last.row == 61 assert last.row == 57
def test_parse_budget_file(budget_example_file): def test_parse_budget_file(budget_example_file):
@ -68,7 +69,7 @@ def test_parse_budget_file(budget_example_file):
result = parse_budget_file(budget_example_file) result = parse_budget_file(budget_example_file)
first = result[0] first = result[0]
assert len(result) == 20 assert len(result) == 19 # the line starting with "Stand" is filtered out
assert first.row == 3 assert first.row == 3
assert first.number == 1 assert first.number == 1
assert first.project_name == "Safeguard IV" assert first.project_name == "Safeguard IV"

2
tests/test_overview.py

@ -86,7 +86,7 @@ def test_create_overview_map(budget_example_file):
budget_data = parse_budget_file(budget_example_file) budget_data = parse_budget_file(budget_example_file)
result = _create_overview_map(budget_data) result = _create_overview_map(budget_data)
assert len(result) == 20 assert len(result) == 19 # the line starting with "Stand" is filtered out
assert "1083013701" in result assert "1083013701" in result
for key, value in result.items(): for key, value in result.items():
assert key == str(value.project) assert key == str(value.project)

Loading…
Cancel
Save