Browse Source

added test script

main
Holger Frey 2 months ago
parent
commit
cd726427dc
  1. BIN
      budgets/Budget-Vorlage-2024.xlsx
  2. 9
      pyproject.toml
  3. 48
      superx_budget/__init__.py

BIN
budgets/Budget-Vorlage-2024.xlsx

Binary file not shown.

9
pyproject.toml

@ -41,6 +41,9 @@ main = "superx_budget:main" @@ -41,6 +41,9 @@ main = "superx_budget:main"
[project.urls]
Source = "https://git.cpi.imtek.uni-freiburg.de/CPI/superx-budget-overview.git"
[project.scripts]
superx_test = "superx_budget:cli_parse_exported_file"
[project.optional-dependencies]
test = [
"pytest >=4.0.0",
@ -57,12 +60,16 @@ dev = [ @@ -57,12 +60,16 @@ dev = [
"ruff",
]
[tool.pytest.ini_options]
markers = [
"fun: marks tests as functional (deselect with '-m \"not fun\"')",
"functional: marks tests as functional (deselect with '-m \"not functional\"')",
]
addopts = [
"--strict-markers",
"--strict-config",
"--showlocals",
"-ra",
]

48
superx_budget/__init__.py

@ -5,6 +5,11 @@ Creating a budget overview from a SuperX export @@ -5,6 +5,11 @@ Creating a budget overview from a SuperX export
__version__ = "0.0.1"
import argparse
import pathlib
import sys
import warnings
from .budget import parse_budget_file # noqa: F401
from .exceptions import BudgetParserError, SuperXParserError # noqa: F401
from .helpers import ( # noqa: F401
@ -17,3 +22,46 @@ from .helpers import ( # noqa: F401 @@ -17,3 +22,46 @@ from .helpers import ( # noqa: F401
from .overview import create_overview # noqa: F401
from .pyramid import main # noqa: F401
from .superx import parse_exported_file # noqa: F401
def cli_parse_exported_file():
parser = argparse.ArgumentParser(
prog="SuperxParserTest",
description="Try to parse a file exported from SuperX",
)
parser.add_argument("filename")
args = parser.parse_args()
with warnings.catch_warnings(action="ignore"):
sys.stderr.write(f"trying to read '{args.filename}'\n")
exported = superx.parse_exported_file(pathlib.Path(args.filename))
sys.stderr.write("... OK\n")
sys.stderr.write(f"searching budget file for year '{exported.account_year}'\n")
budget_dir = pathlib.Path(__file__).parent.parent / "budgets"
budget_file = find_budget_file(
budget_dir, exported.account_year
)
if not budget_file:
sys.exit("... no budget file found")
sys.stderr.write(f"... found '{budget_file}'\n")
sys.stderr.write(f"parsing budget file '{budget_file}'\n")
budget_data = parse_budget_file(budget_file)
sys.stderr.write("... OK\n")
sys.stderr.write(f"Creating overview\n")
overview_map = create_overview(budget_data, exported)
sys.stderr.write("... OK\n")
sys.stderr.write(f"Sorting overview\n")
overview = sorted(overview_map.values(), key=lambda i: i.row)
sys.stderr.write("... OK\n")
sys.stderr.write(f"Geting recipients file\n")
recipients = find_recipients(budget_dir)
sys.stderr.write("... OK\n")
sys.stderr.write(f"Retrieving sheet for export\n")
sheet = get_sheet_of_file(budget_file)
sys.stderr.write("... OK\n")
Loading…
Cancel
Save