Add and fix tests
This commit is contained in:
@@ -269,11 +269,10 @@ async def new_product_post(
|
||||
session: SessionDep,
|
||||
user: UserDep,
|
||||
product_data: Annotated[types.Product, Form()],
|
||||
# product_image: Annotated[bytes, File()]
|
||||
):
|
||||
if not user.has_permission("product", "edit"):
|
||||
raise HTTPException(status_code=403, detail="Insufficient permissions")
|
||||
# print(len(product_image))
|
||||
|
||||
product = Product()
|
||||
|
||||
for field_name, data in product_data.model_dump().items():
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
from decimal import Decimal
|
||||
|
||||
from sqlalchemy import create_engine, select
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
@@ -40,10 +41,12 @@ def ensure_user(user_info: dict, session: Session) -> User:
|
||||
session.add(user)
|
||||
session.flush()
|
||||
|
||||
if not "APS_PRODUCTION_MODE" in os.environ:
|
||||
if not "APS_PRODUCTION_MODE" in os.environ and not "APS_TESTRUN" in os.environ:
|
||||
# when in demo mode each user gets an account with some starting balance
|
||||
account = Account(name=f"Demokonto für {user.display_name}")
|
||||
account.transactions.append(Transaction(total_amount=100.0, type="deposit"))
|
||||
account.transactions.append(
|
||||
Transaction(total_amount=Decimal(100), type="deposit")
|
||||
)
|
||||
user.accounts.append(account)
|
||||
session.flush()
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ class Account(Base):
|
||||
|
||||
@property
|
||||
def balance(self):
|
||||
for t in self.transactions:
|
||||
print(t)
|
||||
return sum(t.total_amount for t in self.transactions)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user