|
|
|
@ -1,18 +1,6 @@
@@ -1,18 +1,6 @@
|
|
|
|
|
import pytest |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture |
|
|
|
|
def example_file(example_root): |
|
|
|
|
return example_root / "Verbrauchsmittel-Toto-2020.xlsx" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture |
|
|
|
|
def example_workbook(example_file): |
|
|
|
|
import openpyxl |
|
|
|
|
|
|
|
|
|
yield openpyxl.open(example_file) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize( |
|
|
|
|
"input,expected", |
|
|
|
|
[ |
|
|
|
@ -53,20 +41,20 @@ def test_strip_excel_value(input, expected):
@@ -53,20 +41,20 @@ def test_strip_excel_value(input, expected):
|
|
|
|
|
assert result == expected |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_sheet_of_file_first(example_file): |
|
|
|
|
def test_get_sheet_of_file_first(budget_example_file): |
|
|
|
|
from superx_budget.helpers import get_sheet_of_file |
|
|
|
|
|
|
|
|
|
sheet = get_sheet_of_file(example_file) # sheet=None |
|
|
|
|
sheet = get_sheet_of_file(budget_example_file) # sheet=None |
|
|
|
|
first_row = next(sheet.values) |
|
|
|
|
first_cell = first_row[0] |
|
|
|
|
|
|
|
|
|
assert first_cell.strip() == "Nr." |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_sheet_of_file_named(example_file): |
|
|
|
|
def test_get_sheet_of_file_named(budget_example_file): |
|
|
|
|
from superx_budget.helpers import get_sheet_of_file |
|
|
|
|
|
|
|
|
|
sheet = get_sheet_of_file(example_file, sheet="Safeguard I") |
|
|
|
|
sheet = get_sheet_of_file(budget_example_file, sheet="Safeguard I") |
|
|
|
|
first_row = next(sheet.values) |
|
|
|
|
first_cell = first_row[0] |
|
|
|
|
|
|
|
|
@ -91,3 +79,35 @@ def test_excel_value_as_number(input, expected):
@@ -91,3 +79,35 @@ def test_excel_value_as_number(input, expected):
|
|
|
|
|
result = excel_value_as_number(input) |
|
|
|
|
|
|
|
|
|
assert result == expected |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_find_budget_file_found(example_root): |
|
|
|
|
from superx_budget.helpers import find_budget_file |
|
|
|
|
|
|
|
|
|
result = find_budget_file(example_root, 2020) |
|
|
|
|
|
|
|
|
|
assert result.name == "Budget-Vorlage-2020.xlsx" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_find_budget_file_not_found(example_root): |
|
|
|
|
from superx_budget.helpers import find_budget_file |
|
|
|
|
|
|
|
|
|
result = find_budget_file(example_root, 2019) |
|
|
|
|
|
|
|
|
|
assert result is None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_find_recipients_ok(example_root): |
|
|
|
|
from superx_budget.helpers import find_recipients |
|
|
|
|
|
|
|
|
|
result = find_recipients(example_root, "recipients.txt") |
|
|
|
|
|
|
|
|
|
assert result == ["frey@imtek.de", "foo@example.com", "bar@example.com"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_find_recipients_default(example_root): |
|
|
|
|
from superx_budget.helpers import find_recipients |
|
|
|
|
|
|
|
|
|
result = find_recipients(example_root, "unknown file") |
|
|
|
|
|
|
|
|
|
assert result == ["frey@imtek.de"] |
|
|
|
|