示例#1
0
def create_auction(*,
                   auction_in: AuctionCreate,
                   ending_date: datetime = Body(...),
                   db: Session = Depends(get_db),
                   current_user: User = Depends(get_current_active_user)):
    return auction_repo.create_with_owner(db,
                                          obj_in=auction_in,
                                          owner_id=current_user.id,
                                          ending_date=ending_date)
示例#2
0
def create_random_auction(db: Session) -> Auction:

    product = create_random_product(db)
    starting_amount = random_float()
    reserve = starting_amount + random_float() + 2
    bid_cap = reserve + random_float() + 2
    owner = product.owner

    return auction_repo.create_with_owner(db,
                                          obj_in=AuctionCreate(
                                              product_id=product.id,
                                              owner_id=owner.id,
                                              starting_amount=starting_amount,
                                              reserve=reserve,
                                              bid_cap=bid_cap),
                                          owner_id=owner.id)
示例#3
0
def test_create_auction(db: Session):
    product = create_random_product(db)
    starting_amount = random_float()
    reserve = starting_amount + random_float()
    bid_cap = reserve + random_float()
    owner = product.owner

    auction = auction_repo.create_with_owner(
        db,
        obj_in=AuctionCreate(product_id=product.id,
                             starting_amount=starting_amount,
                             reserve=reserve,
                             bid_cap=bid_cap),
        owner_id=owner.id)

    db_obj = auction_repo.get(db, id=auction.id)

    assert db_obj
    assert db_obj.product_id == product.id
    assert db_obj.owner_id == owner.id
    assert db_obj.starting_amount == starting_amount
    assert db_obj.reserve == reserve
    assert db_obj.bid_cap == bid_cap
    assert db_obj.state == AuctionState.CREATED
示例#4
0
def create_auction(*,
                   auction_in: AuctionCreate,
                   db: Session = Depends(get_db),
                   current_user: User = Depends(get_current_active_user)):
    return auction_repo.create_with_owner(db, obj_in=auction_in, owner_id=current_user.id)