Backend: Product.updated_at (Zuletzt geaendert)
Neue Spalte updated_at, die bei jeder Stammdaten-Aenderung automatisch nachzieht (onupdate). Migration legt sie nullable an und setzt Altbestaende auf created_at. In ProductOut ausgegeben - Basis fuer eine "Zuletzt geaendert"-Spalte im Web. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -331,3 +331,20 @@ def test_verbrauchsgegenstand_unter_mindestbestand(db):
|
||||
db.commit()
|
||||
# Unter dem Mindestbestand -> gehört auf die Einkaufsliste (wie ein Lebensmittel).
|
||||
assert current_stock(db, product.id) < product.min_stock
|
||||
|
||||
|
||||
# ---- Zuletzt geändert ----
|
||||
|
||||
def test_updated_at_wird_bei_aenderung_nachgezogen(db):
|
||||
import time
|
||||
product = Product(name="Alt")
|
||||
db.add(product)
|
||||
db.commit()
|
||||
db.refresh(product)
|
||||
erst = product.updated_at
|
||||
assert erst is not None
|
||||
time.sleep(0.01)
|
||||
product.name = "Neu"
|
||||
db.commit()
|
||||
db.refresh(product)
|
||||
assert product.updated_at > erst
|
||||
|
||||
Reference in New Issue
Block a user