feat: Projekt-Geruest finance/ mit Config und Test-Setup

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 17:04:59 +02:00
parent d4a98e117f
commit 53ffd65104
8 changed files with 60 additions and 0 deletions

5
finance/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
.env
__pycache__/
*.sqlite
tests/fixtures/*.pdf
.venv/

0
finance/app/__init__.py Normal file
View File

34
finance/app/config.py Normal file
View File

@@ -0,0 +1,34 @@
import os
from dataclasses import dataclass
from decimal import Decimal
from functools import lru_cache
from pathlib import Path
@dataclass(frozen=True)
class Settings:
database_url: str
api_key: str
gui_user: str
gui_password_hash: str
session_secret: str
inbox_dir: Path
uploads_dir: Path
warn_threshold: Decimal
horizon_days: int
@lru_cache
def get_settings() -> Settings:
e = os.environ.get
return Settings(
database_url=e("FB_DATABASE_URL", "sqlite:///./fb.sqlite"),
api_key=e("FB_API_KEY", ""),
gui_user=e("FB_GUI_USER", "admin"),
gui_password_hash=e("FB_GUI_PASSWORD_HASH", ""),
session_secret=e("FB_SESSION_SECRET", "dev-secret"),
inbox_dir=Path(e("FB_INBOX_DIR", "./inbox")),
uploads_dir=Path(e("FB_UPLOADS_DIR", "./uploads")),
warn_threshold=Decimal(e("FB_WARN_THRESHOLD", "0")),
horizon_days=int(e("FB_HORIZON_DAYS", "548")),
)

2
finance/pytest.ini Normal file
View File

@@ -0,0 +1,2 @@
[pytest]
testpaths = tests

View File

@@ -0,0 +1,3 @@
-r requirements.txt
pytest==8.4.1
httpx==0.28.1

9
finance/requirements.txt Normal file
View File

@@ -0,0 +1,9 @@
fastapi==0.116.1
uvicorn==0.35.0
sqlalchemy==2.0.41
alembic==1.16.2
psycopg[binary]==3.2.9
jinja2==3.1.6
python-multipart==0.0.20
itsdangerous==2.2.0
pdfplumber==0.11.7

View File

View File

@@ -0,0 +1,7 @@
from app.config import get_settings
def test_defaults():
s = get_settings()
assert s.horizon_days == 548
assert s.gui_user == "admin"