def create_product_with_thing_type( thing_name: str = "Test Book", thing_type: ThingType = ThingType.LIVRE_EDITION, author_name: str = "Test Author", is_national: bool = False, id_at_providers: str = None, idx: int = None, is_digital: bool = False, is_gcu_compatible: bool = True, is_offline_only: bool = False, date_modified_at_last_provider: datetime = None, last_provider_id: int = None, media_urls: Iterable[str] = ("test/urls", ), description: str = None, thumb_count: int = 1, url: str = None, owning_offerer: Offerer = None, extra_data: Dict = None, ) -> Product: product = Product() product.id = idx product.type = str(thing_type) product.name = thing_name product.description = description if extra_data: product.extraData = extra_data else: product.extraData = {"author": author_name} product.isNational = is_national if id_at_providers is None: id_at_providers = "".join(random.choices(string.digits, k=13)) product.dateModifiedAtLastProvider = date_modified_at_last_provider product.lastProviderId = last_provider_id product.idAtProviders = id_at_providers product.isGcuCompatible = is_gcu_compatible product.mediaUrls = media_urls product.thumbCount = thumb_count product.url = url product.owningOfferer = owning_offerer product.description = description if is_digital: product.url = "fake/url" if is_offline_only: product.type = str(ThingType.CINEMA_ABO) return product
def create_product_with_event_type( event_name: str = "Test event", event_type: EventType = EventType.SPECTACLE_VIVANT, description: str = None, duration_minutes: Optional[int] = 60, id_at_providers: str = None, is_national: bool = False, is_duo: bool = False, thumb_count: int = 0, ) -> Product: product = Product() product.name = event_name product.description = description product.durationMinutes = duration_minutes product.thumbCount = thumb_count product.idAtProviders = id_at_providers product.isNational = is_national product.isDuo = is_duo product.type = str(event_type) product.description = description return product