fix: Kredit-Ausgabe ohne Laufzeit-Grenze (A14-T5 Fixrunde)

LoanOut erbt nicht mehr von LoanIn - definiert term_months ohne Grenzen.
Altbestände mit term_months>1200 (vor Validierung direkt eingefügt)
crashen GET /api/loans und PATCH nicht mehr.

Regression-Test: test_altbestand_kredit_mit_laufzeit_ausserhalb_grenzen
- Inseriert Loan mit term_months=1500 direkt via DB
- Bestätigt GET /api/loans und Ausgabe-Serialisierung funktioniert
- Keine Validierung auf Output

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-30 13:14:14 +02:00
co-authored by Claude Haiku 4.5
parent 80b8b369c7
commit 94fd7ab96e
2 changed files with 25 additions and 1 deletions
+17
View File
@@ -392,3 +392,20 @@ def test_kredit_laufzeit_grenzen_und_patch(client):
assert client.patch(url, headers=H, json={"term_months": 1201}).status_code == 422
r = client.patch(url, headers=H, json={"term_months": 1200})
assert r.status_code == 200 and r.json()["term_months"] == 1200
def test_altbestand_kredit_mit_laufzeit_ausserhalb_grenzen(client, db):
"""Regression: Kredite die vor Validierung direkt in DB eingefügt wurden
(term_months>1200 möglich) dürfen GET /api/loans nicht crashen.
LoanOut-Ausgabe muss Altbestände ohne Validierung unterstützen."""
from app.models.tables import Loan
from decimal import Decimal
old_loan = Loan(name="Legacy", principal=Decimal("500.00"), annual_rate_pct=Decimal("2.0"),
term_months=1500, payout_date=date(2025, 1, 1), repayment_type="annuity")
db.add(old_loan)
db.commit()
r = client.get("/api/loans", headers=H)
assert r.status_code == 200
loans = r.json()
found = [l for l in loans if l["term_months"] == 1500]
assert len(found) == 1 and found[0]["name"] == "Legacy"