def fill_object_attributes(self, product: Product): product.name = trim_with_elipsis(self.product_infos["titre"], 140) product.datePublished = read_things_date( self.product_infos["date_parution"]) product.type = self.product_type product.extraData = self.product_extra_data.copy() product.extraData.update(get_extra_data_from_infos(self.product_infos)) if self.product_infos["url_extrait_pdf"] != "": if product.mediaUrls is None: product.mediaUrls = [] product.mediaUrls.append(self.product_infos["url_extrait_pdf"])
def fill_object_attributes(self, product: Product): product.name = trim_with_elipsis(self.product_infos["titre"], 140) product.datePublished = read_things_date( self.product_infos["date_parution"]) subcategory = subcategories.ALL_SUBCATEGORIES_DICT[ self.product_subcategory_id] product.subcategoryId = subcategory.id product.extraData = self.product_extra_data.copy() product.extraData.update(get_extra_data_from_infos(self.product_infos)) if self.product_infos["url_extrait_pdf"] != "": if product.mediaUrls is None: product.mediaUrls = [] product.mediaUrls.append(self.product_infos["url_extrait_pdf"])
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