def create_offer_with_event_product( venue: Venue = None, booking_email: str = "*****@*****.**", criteria: List[Criterion] = None, date_created: datetime = datetime.utcnow(), description: Optional[str] = None, duration_minutes: Optional[int] = 60, event_name: str = "Test event", event_type: EventType = EventType.SPECTACLE_VIVANT, id_at_providers: str = None, idx: int = None, is_active: bool = True, is_duo: bool = False, is_national: bool = False, last_provider_id: int = None, product: Product = None, last_provider: Provider = None, thumb_count: int = 0, withdrawal_details: Optional[str] = None, ) -> Offer: offer = Offer() if product is None: product = create_product_with_event_type( event_name=event_name, event_type=event_type, duration_minutes=duration_minutes, thumb_count=thumb_count, is_national=is_national, ) if criteria: offer.criteria = criteria offer.product = product offer.venue = venue offer.name = product.name offer.type = product.type offer.description = description offer.isNational = product.isNational offer.durationMinutes = product.durationMinutes offer.dateCreated = date_created offer.bookingEmail = booking_email offer.isActive = is_active offer.id = idx offer.lastProviderId = last_provider_id offer.lastProvider = last_provider offer.idAtProviders = id_at_providers offer.isDuo = is_duo offer.withdrawalDetails = withdrawal_details return offer
def create_offer_with_thing_product( venue: VenueSQLEntity, author_name: str = "Test Author", booking_email: Optional[str] = "*****@*****.**", date_created: datetime = datetime.utcnow(), description: Optional[str] = None, id_at_providers: str = None, idx: int = None, is_active: bool = True, is_digital: bool = False, is_national: bool = False, is_offline_only: bool = False, media_urls: Iterable[str] = ("test/urls", ), product: Product = None, thing_name: str = "Test Book", thing_type: ThingType = ThingType.AUDIOVISUEL, thumb_count: int = 0, url: Optional[str] = None, last_provider_id: int = None, last_provider: Provider = None, extra_data: Dict = None, withdrawal_details: Optional[str] = None, ) -> Offer: offer = Offer() if product: offer.product = product offer.productId = product.id offer.name = product.name offer.type = product.type offer.mediaUrls = product.mediaUrls offer.extraData = product.extraData offer.url = product.url offer.isNational = product.isNational offer.description = product.description else: if is_digital: url = "fake/url" if is_offline_only: thing_type = ThingType.CINEMA_ABO offer.product = create_product_with_thing_type( thing_name=thing_name, thing_type=thing_type, media_urls=media_urls, author_name=author_name, url=url, thumb_count=thumb_count, is_national=is_national, description=description, ) offer.name = thing_name offer.type = str(thing_type) offer.mediaUrls = media_urls offer.extraData = {"author": author_name} offer.url = url offer.isNational = is_national offer.description = description offer.venue = venue offer.dateCreated = date_created offer.bookingEmail = booking_email offer.isActive = is_active offer.lastProviderId = last_provider_id offer.lastProvider = last_provider offer.id = idx offer.withdrawalDetails = withdrawal_details if extra_data: offer.extraData = extra_data if id_at_providers: offer.idAtProviders = id_at_providers elif venue is not None: offer.idAtProviders = "%s@%s" % (offer.product.idAtProviders, venue.siret or venue.id) return offer