feat: Szenario per GUI löschen, Name System-Ist reserviert (A11-T1)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-28 19:01:21 +02:00
co-authored by Claude Opus 5.5
parent 1c452b48de
commit 57ab6dae4a
5 changed files with 64 additions and 0 deletions
+24
View File
@@ -1,6 +1,8 @@
from datetime import date, timedelta
from decimal import Decimal
import pytest
from app.models.tables import Account, Transaction
from app.services.balances import account_balance
@@ -294,3 +296,25 @@ def test_scenario_planned_patch(client, db):
r = client.patch(f"/api/scenarios/{other['id']}/planned/{p['id']}", headers=H, json={
"name": "x", "amount": "1.00", "due": "2026-08-15"})
assert r.status_code == 404
@pytest.mark.parametrize("name", ["System-Ist", "system-ist", " System-Ist ", "SYSTEM-IST"])
def test_szenario_name_system_ist_ist_reserviert_post(client, name):
r = client.post("/api/scenarios", json={"name": name}, headers=H)
assert r.status_code == 422
assert "reserviert" in r.json()["detail"]
def test_szenario_name_system_ist_ist_reserviert_patch(client):
sid = client.post("/api/scenarios", json={"name": "Normal"}, headers=H).json()["id"]
r = client.patch(f"/api/scenarios/{sid}", json={"name": "System-Ist"}, headers=H)
assert r.status_code == 422
assert "reserviert" in r.json()["detail"]
# Andere Felder ohne Namensänderung bleiben erlaubt.
r = client.patch(f"/api/scenarios/{sid}", json={"description": "x"}, headers=H)
assert r.status_code == 200
def test_szenario_normale_namen_weiter_erlaubt(client):
assert client.post("/api/scenarios", json={"name": "Ist-Zustand plus"},
headers=H).status_code == 201
+21
View File
@@ -483,3 +483,24 @@ def test_grafana_links_fallback_to_host_port_when_unset(client, monkeypatch):
assert "fb.example.de" not in r.text
finally:
get_settings.cache_clear()
def test_szenarien_seite_hat_loeschen_button(client, db):
client.post("/login", data={"username": "admin", "password": "geheim"})
sc = Scenario(name="Wegwerf", description="", include_recurring=True,
include_planned=True)
db.add(sc)
db.commit()
r = client.get("/szenarien")
assert f'hx-delete="/api/scenarios/{sc.id}"' in r.text
assert 'Szenario „Wegwerf" mit allen Einträgen wirklich löschen?' in r.text
def test_szenario_loeschen_roundtrip_gui(client, db):
client.post("/login", data={"username": "admin", "password": "geheim"})
sc = Scenario(name="Wegwerf-Roundtrip", description="", include_recurring=True,
include_planned=True)
db.add(sc)
db.commit()
assert client.delete(f"/api/scenarios/{sc.id}", headers=H).status_code == 204
assert "Wegwerf-Roundtrip" not in client.get("/szenarien").text