You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
2.5 KiB
117 lines
2.5 KiB
import pytest |
|
|
|
|
|
@pytest.mark.parametrize( |
|
"input,expected", |
|
[ |
|
("a", False), |
|
("", True), |
|
(" ", True), |
|
(" a ", False), |
|
(None, True), |
|
(0, False), |
|
(2.2, False), |
|
], |
|
) |
|
def test_is_empty_excel_value(input, expected): |
|
from superx_budget.helpers import is_empty_excel_value |
|
|
|
result = is_empty_excel_value(input) |
|
|
|
assert result == expected |
|
|
|
|
|
@pytest.mark.parametrize( |
|
"input,expected", |
|
[ |
|
("a", "a"), |
|
("", ""), |
|
(" ", ""), |
|
(" a ", "a"), |
|
(None, None), |
|
(1, 1), |
|
(2.2, 2.2), |
|
], |
|
) |
|
def test_strip_excel_value(input, expected): |
|
from superx_budget.helpers import strip_excel_value |
|
|
|
result = strip_excel_value(input) |
|
|
|
assert result == expected |
|
|
|
|
|
def test_get_sheet_of_file_first(budget_example_file): |
|
from superx_budget.helpers import get_sheet_of_file |
|
|
|
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(budget_example_file): |
|
from superx_budget.helpers import get_sheet_of_file |
|
|
|
sheet = get_sheet_of_file(budget_example_file, sheet="Safeguard I") |
|
first_row = next(sheet.values) |
|
first_cell = first_row[0] |
|
|
|
assert first_cell == 1 |
|
|
|
|
|
@pytest.mark.parametrize( |
|
"input,expected", |
|
[ |
|
(None, 0), |
|
("", 0), |
|
("a", 0), |
|
("1", 1.0), |
|
("2.4", 2.4), |
|
(1, 1), |
|
(2.4, 2.4), |
|
], |
|
) |
|
def test_excel_value_as_number(input, expected): |
|
from superx_budget.helpers import excel_value_as_number |
|
|
|
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", |
|
"imtek@holgerfrey.de", |
|
"superx@holgerfrey.de", |
|
] |
|
|
|
|
|
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"]
|
|
|