Fix: /breeder/my-editor Endpoint (Crash 'Cannot destructure profile') + Läufigkeit in Züchter-Bereich
breeder-editor.js (aus 459cd42) rief /api/breeder/my-editor auf — Endpoint
existierte nie (gleicher Worktree-Verlust wie /partner/my-profile). Jetzt
gebaut: profile + litters + storage_mb/limit; ohne Profil klare 404 statt
Destrukturierungs-Crash. 3 Tests.
Läufigkeit (Rene): eigener HUND-Chip entfällt, stattdessen vierte Karte im
Züchter-Bereich (Zyklen, Progesterontests, Deckdaten). Suite: 58 passed.
This commit is contained in:
parent
ed7c469c6a
commit
487dacc7c7
9 changed files with 100 additions and 20 deletions
33
tests/test_breeder_editor.py
Normal file
33
tests/test_breeder_editor.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
"""Smoke-Tests fuer den Zuechter-Profil-Editor-Endpoint (/breeder/my-editor)."""
|
||||
|
||||
|
||||
def test_my_editor_requires_breeder(client, user):
|
||||
r = client.get("/api/breeder/my-editor", headers=user["headers"])
|
||||
assert r.status_code == 403
|
||||
|
||||
|
||||
def test_my_editor_without_profile_404(client, admin):
|
||||
"""Admin ohne Zuechterprofil -> klare 404-Meldung statt Frontend-Crash."""
|
||||
r = client.get("/api/breeder/my-editor", headers=admin["headers"])
|
||||
assert r.status_code == 404
|
||||
assert "Profil" in r.json()["detail"]
|
||||
|
||||
|
||||
def test_my_editor_with_profile(client, user):
|
||||
"""Zuechter mit Profil -> profile + litters + storage."""
|
||||
from database import db
|
||||
with db() as conn:
|
||||
uid = conn.execute("SELECT id FROM users WHERE email=?", (user["email"],)).fetchone()["id"]
|
||||
conn.execute("UPDATE users SET rolle='breeder' WHERE id=?", (uid,))
|
||||
conn.execute(
|
||||
"""INSERT INTO breeder_profiles (user_id, zwingername, rasse_text, verein, stadt)
|
||||
VALUES (?,?,?,?,?)""",
|
||||
(uid, "Vom Teststall", "Labrador", "VDH", "Ebersberg")
|
||||
)
|
||||
r = client.get("/api/breeder/my-editor", headers=user["headers"])
|
||||
assert r.status_code == 200, r.text
|
||||
d = r.json()
|
||||
assert d["profile"]["zwingername"] == "Vom Teststall"
|
||||
assert isinstance(d["litters"], list)
|
||||
assert d["storage_limit_mb"] == 200
|
||||
assert d["storage_mb"] >= 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue