fix: PATCH-Buchung ohne Feld laesst Kategorie unveraendert, 404 bei unbekannter Kategorie
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -48,3 +48,32 @@ def test_rules_categorize(client):
|
||||
txs = client.get("/api/transactions", headers=H,
|
||||
params={"account_id": acc["id"]}).json()
|
||||
assert txs[0]["category_id"] == cat["id"]
|
||||
|
||||
|
||||
def test_patch_transaction_category(client):
|
||||
cat = client.post("/api/categories", headers=H, json={"name": "Freizeit"}).json()
|
||||
acc = client.post("/api/accounts", headers=H, json={
|
||||
"bank": "DKB", "iban": "DE77", "name": "G3", "type": "giro"}).json()
|
||||
tx = client.post("/api/transactions", headers=H, json={
|
||||
"account_id": acc["id"], "booking_date": "2026-07-04",
|
||||
"amount": "-15.00", "purpose": "Kino", "counterparty": ""}).json()
|
||||
tx_id = tx["id"]
|
||||
assert tx["category_id"] is None
|
||||
|
||||
r = client.patch(f"/api/transactions/{tx_id}", headers=H,
|
||||
json={"category_id": cat["id"]})
|
||||
assert r.status_code == 200
|
||||
assert r.json()["category_id"] == cat["id"]
|
||||
|
||||
r = client.patch(f"/api/transactions/{tx_id}", headers=H, json={})
|
||||
assert r.status_code == 200
|
||||
assert r.json()["category_id"] == cat["id"]
|
||||
|
||||
r = client.patch(f"/api/transactions/{tx_id}", headers=H,
|
||||
json={"category_id": None})
|
||||
assert r.status_code == 200
|
||||
assert r.json()["category_id"] is None
|
||||
|
||||
r = client.patch(f"/api/transactions/{tx_id}", headers=H,
|
||||
json={"category_id": 9999})
|
||||
assert r.status_code == 404
|
||||
|
||||
Reference in New Issue
Block a user