item.py 545 B

123456789101112131415
  1. from app import crud
  2. from app.models import Item, ItemCreate
  3. from app.tests.utils.user import create_random_user
  4. from app.tests.utils.utils import random_lower_string
  5. from sqlmodel import Session
  6. def create_random_item(db: Session) -> Item:
  7. user = create_random_user(db)
  8. owner_id = user.id
  9. assert owner_id is not None
  10. title = random_lower_string()
  11. description = random_lower_string()
  12. item_in = ItemCreate(title=title, description=description)
  13. return crud.create_item(session=db, item_in=item_in, owner_id=owner_id)