feat: PDF-Parser VR/HVB/DKB mit Registry und Fixture-Tests
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
9
finance/tests/fixtures/README.md
vendored
Normal file
9
finance/tests/fixtures/README.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Beispiel-Auszüge (nicht committen!)
|
||||
|
||||
Hier pro Bank mindestens einen echten PDF-Kontoauszug ablegen:
|
||||
- `vr_beispiel.pdf` (Volksbank/Raiffeisenbank)
|
||||
- `hvb_beispiel.pdf` (HypoVereinsbank)
|
||||
- `dkb_beispiel.pdf` (DKB)
|
||||
|
||||
Beträge dürfen verfremdet sein, das Layout muss echt sein.
|
||||
PDFs sind via .gitignore vom Repo ausgeschlossen.
|
||||
24
finance/tests/test_bank_parsers.py
Normal file
24
finance/tests/test_bank_parsers.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from app.parsers.registry import parse_pdf
|
||||
from app.parsers.validate import balance_difference
|
||||
|
||||
FIXTURES = Path(__file__).parent / "fixtures"
|
||||
CASES = [("vr_beispiel.pdf", "vr"), ("hvb_beispiel.pdf", "hvb"),
|
||||
("dkb_beispiel.pdf", "dkb")]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("filename,bank", CASES)
|
||||
def test_parse_fixture(filename, bank):
|
||||
path = FIXTURES / filename
|
||||
if not path.exists():
|
||||
pytest.skip(f"Fixture {filename} fehlt")
|
||||
stmt = parse_pdf(path)
|
||||
assert stmt.bank == bank
|
||||
assert stmt.opening_balance is not None
|
||||
assert stmt.closing_balance is not None
|
||||
assert len(stmt.transactions) > 0
|
||||
assert balance_difference(stmt) == Decimal("0")
|
||||
Reference in New Issue
Block a user