Backend: - Modelle + Migration 0002: accounts, account_identifiers, category_groups, categories, transactions, exchange_rates (alle owner-gescoped). - EZB-Kursdienst (90-Tage/Historie) + Backfill-Skript; Umrechnung EUR<->CHF zum Buchungsdatum mit lokalem Cache und manueller Übersteuerung; EUR-Pivot (amount_eur_cents) eingefroren. - Kontostände + Netto-Vermögen (Umrechnung in Hauptwährung). - Router: accounts (inkl. IBAN-Identifikatoren), categories (Gruppen+Kategorien), transactions (Ausgabe/Einnahme/Transfer, cross-currency), rates. - Gruppierte Standard-Kategorien je Nutzer beim Anlegen. - pytest-Suite: Währung, Salden, Cross-Currency-Transfer, Nutzer-Isolation. Frontend: - Seiten Konten, Kategorien, Buchungen; Icon-Chip, Geldbetrag mit Umrechnung, Icon-/Farbwähler, Modal; erweitertes SVG-Icon-Set (Konto-/Kategorie-Icons). - Währungs-/Datumsformatierung (EUR de-DE, CHF de-CH), i18n DE/EN erweitert. - Live-Umrechnungs-Vorschau im Transfer-Formular. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""Test-Setup: frische SQLite-DB je Testlauf, kein EZB-Netzabruf."""
|
|
|
|
import os
|
|
import secrets
|
|
import tempfile
|
|
|
|
# Umgebung setzen, BEVOR app importiert wird (config wird beim Import gelesen).
|
|
os.environ.setdefault("APP_DATA_DIR", tempfile.mkdtemp(prefix="cf-test-"))
|
|
os.environ.setdefault("APP_ECB_FETCH_ON_START", "false")
|
|
os.environ.setdefault("APP_ADMIN_USERNAME", "admin")
|
|
os.environ.setdefault("APP_ADMIN_PASSWORD", "adminpass")
|
|
os.environ.setdefault("APP_SESSION_SECRET", "test-secret")
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
@pytest.fixture()
|
|
def client():
|
|
from app.main import app
|
|
|
|
with TestClient(app) as c:
|
|
yield c
|
|
|
|
|
|
@pytest.fixture()
|
|
def admin(client):
|
|
r = client.post("/api/auth/login", data={"username": "admin", "password": "adminpass"})
|
|
assert r.status_code == 200
|
|
return client
|
|
|
|
|
|
def new_user(admin_client) -> tuple[str, str]:
|
|
"""Legt (als Admin) einen frischen Nutzer an und gibt (username, passwort) zurück."""
|
|
username = "u_" + secrets.token_hex(4)
|
|
password = "pw_" + secrets.token_hex(4)
|
|
r = admin_client.post("/api/users", json={"username": username, "password": password, "role": "user"})
|
|
assert r.status_code == 201, r.text
|
|
return username, password
|