Exemplo n.º 1
0
def test_should_return_thing_specific_data_for_email_when_offer_is_a_thing():
    booking = make_booking(
        stock__offer__product__type=str(models.ThingType.AUDIOVISUEL),
        stock__offer__name="Super bien culturel",
    )
    mediation = offers_factories.MediationFactory(offer=booking.stock.offer)

    email_data = retrieve_data_for_beneficiary_booking_confirmation_email(
        booking)

    expected = get_expected_base_email_data(
        booking,
        mediation,
        all_things_not_virtual_thing=1,
        event_date="",
        event_hour="",
        is_event=0,
        is_single_event=0,
        offer_name="Super bien culturel",
        can_expire=1,
    )
    assert email_data == expected
Exemplo n.º 2
0
    def test_add_expiration_date_from_activation_code(self):
        booking = bookings_factories.IndividualBookingFactory(
            quantity=10,
            stock__price=0,
            stock__offer__product__subcategoryId=subcategories.VOD.id,
            stock__offer__product__url="http://example.com",
            stock__offer__name="Super offre numérique",
            dateCreated=datetime.utcnow(),
        )
        offers_factories.ActivationCodeFactory(
            stock=booking.stock,
            booking=booking,
            code="code_toto",
            expirationDate=datetime(2030, 1, 1),
        )
        mediation = offers_factories.MediationFactory(offer=booking.stock.offer)

        email_data = retrieve_data_for_beneficiary_booking_confirmation_email(booking.individualBooking)

        expected = get_expected_base_email_data(
            booking,
            mediation,
            all_but_not_virtual_thing=0,
            all_things_not_virtual_thing=0,
            event_date="",
            event_hour="",
            is_event=0,
            is_single_event=0,
            offer_name="Super offre numérique",
            offer_price="Gratuit",
            can_expire=0,
            offer_token="code_toto",
            code_expiration_date="1 janvier 2030",
            has_offer_url=1,
            digital_offer_url="http://example.com",
            expiration_delay="",
        )
        assert email_data == expected
Exemplo n.º 3
0
    def test_should_return_new_expiration_delay_data_for_email_when_offer_is_a_book(self):
        booking = bookings_factories.IndividualBookingFactory(
            stock__offer__product__subcategoryId=subcategories.LIVRE_PAPIER.id,
            stock__offer__name="Super livre",
            dateCreated=datetime.utcnow(),
        )
        mediation = offers_factories.MediationFactory(offer=booking.stock.offer)

        email_data = retrieve_data_for_beneficiary_booking_confirmation_email(booking.individualBooking)

        expected = get_expected_base_email_data(
            booking,
            mediation,
            all_things_not_virtual_thing=1,
            event_date="",
            event_hour="",
            is_event=0,
            is_single_event=0,
            offer_name="Super livre",
            can_expire=1,
            expiration_delay=10,
        )
        assert email_data == expected
    def test_should_not_return_booking_when_favorite_offer_booking_is_cancelled(
            self, app):
        # given
        beneficiary = users_factories.UserFactory()
        stock = offers_factories.StockFactory()
        bookings_factories.CancelledBookingFactory(
            stock=stock,
            user=beneficiary,
        )
        offer = stock.offer
        mediation = offers_factories.MediationFactory(offer=offer)
        favorite = users_factories.FavoriteFactory(mediation=mediation,
                                                   offer=offer,
                                                   user=beneficiary)

        # when
        favorites = repository.find_favorites_domain_by_beneficiary(
            beneficiary.id)

        # then
        assert len(favorites) == 1
        favorite = favorites[0]
        assert favorite.is_booked is False
Exemplo n.º 5
0
def test_should_return_thing_specific_data_for_email_when_offer_is_a_thing():
    stock = offers_factories.ThingStockFactory(
        price=23.99,
        offer__product__subcategoryId=subcategories.SUPPORT_PHYSIQUE_FILM.id,
        offer__name="Super bien culturel",
    )
    booking = bookings_factories.IndividualBookingFactory(stock=stock, dateCreated=datetime.utcnow())
    mediation = offers_factories.MediationFactory(offer=booking.stock.offer)

    email_data = retrieve_data_for_beneficiary_booking_confirmation_email(booking.individualBooking)

    expected = get_expected_base_email_data(
        booking,
        mediation,
        all_things_not_virtual_thing=1,
        event_date="",
        event_hour="",
        is_event=0,
        is_single_event=0,
        offer_name="Super bien culturel",
        can_expire=1,
        expiration_delay=30,
    )
    assert email_data == expected
    def test_should_return_booking_when_favorite_offer_is_booked(self, app):
        # given
        beneficiary = users_factories.UserFactory()
        venue = offers_factories.VenueFactory()
        offer = offers_factories.ThingOfferFactory(venue=venue)
        stock = offers_factories.StockFactory(offer=offer, price=0)
        booking = bookings_factories.IndividualBookingFactory(
            stock=stock, individualBooking__user=beneficiary)
        mediation = offers_factories.MediationFactory(offer=offer)
        favorite = users_factories.FavoriteFactory(mediation=mediation,
                                                   offer=offer,
                                                   user=beneficiary)

        # when
        favorites = repository.find_favorites_domain_by_beneficiary(
            beneficiary.id)

        # then
        assert len(favorites) == 1
        favorite = favorites[0]
        assert favorite.is_booked is True
        assert favorite.booking_identifier == booking.id
        assert favorite.booked_stock_identifier == stock.id
        assert favorite.booking_quantity == booking.quantity
Exemplo n.º 7
0
 def test_ignore_inactive_mediations(self):
     mediation = factories.MediationFactory(isActive=False)
     assert mediation.offer.activeMediation is None
Exemplo n.º 8
0
 def test_active_mediation(self):
     mediation1 = factories.MediationFactory()
     offer = mediation1.offer
     mediation2 = factories.MediationFactory(offer=offer)
     assert offer.activeMediation == mediation2
Exemplo n.º 9
0
 def test_use_mediation(self):
     mediation = factories.MediationFactory(thumbCount=1)
     offer = mediation.offer
     assert offer.thumbUrl.startswith("http")
     assert offer.thumbUrl == mediation.thumbUrl