示例#1
0
    def test_raise_if_zero_or_negative_on_single(self, quantity):
        offer = offers_factories.OfferFactory()

        with pytest.raises(exceptions.QuantityIsInvalid) as error:
            validation.check_quantity(offer, 0)
        assert error.value.errors["quantity"] == [
            "Vous ne pouvez réserver qu'une place pour cette offre."
        ]
示例#2
0
    def test_raise_if_zero_or_negative_on_duo(self, quantity):
        offer = offers_factories.OfferFactory(isDuo=True)

        with pytest.raises(exceptions.QuantityIsInvalid) as error:
            validation.check_quantity(offer, 0)
        assert error.value.errors["quantity"] == [
            "Vous devez réserver une place ou deux dans le cas d'une offre DUO."
        ]
def create_booking_for_user_on_specific_stock_bypassing_capping_limits(
        user_id: int, stock_id: int) -> None:
    stock = Stock.query.get(stock_id)
    user = User.query.get(user_id)
    quantity = 1

    validation.check_offer_already_booked(user, stock.offer)
    validation.check_quantity(stock.offer, quantity)
    validation.check_can_book_free_offer(user, stock)
    validation.check_stock_is_bookable(stock)

    booking = models.Booking()
    # FIXME: this is not right. PcObject's constructor should allow
    # `Booking(stock=stock, ...)`
    booking.userId = user.id
    booking.stockId = stock.id
    booking.amount = stock.price
    booking.quantity = quantity
    booking.token = random_token()
    repository.save(booking)

    redis.add_offer_id(client=app.redis_client, offer_id=stock.offerId)
示例#4
0
 def test_ok_on_duo(self, quantity):
     offer = offers_factories.OfferFactory(isDuo=True)
     validation.check_quantity(offer, quantity)  # should not raise
示例#5
0
 def test_ok_on_single(self):
     offer = offers_factories.OfferFactory()
     validation.check_quantity(offer, 1)  # should not raise