def create_stock( beginning_datetime: Optional[datetime] = None, booking_limit_datetime: Optional[datetime] = None, date_created: datetime = datetime.utcnow(), date_modified: datetime = datetime.utcnow(), date_modified_at_last_provider: Optional[datetime] = None, idx: Optional[int] = None, id_at_providers: Optional[str] = None, is_soft_deleted: bool = False, last_provider_id: Optional[int] = None, offer: Optional[Offer] = None, price: float = 10, quantity: Optional[int] = None, ) -> Stock: stock = Stock() stock.quantity = quantity stock.beginningDatetime = beginning_datetime stock.bookingLimitDatetime = booking_limit_datetime stock.dateCreated = date_created stock.dateModified = date_modified stock.dateModifiedAtLastProvider = date_modified_at_last_provider if idx: stock.id = idx stock.idAtProviders = id_at_providers stock.isSoftDeleted = is_soft_deleted stock.lastProviderId = last_provider_id stock.offer = offer stock.price = price return stock
def test_get_last_update_for_provider_should_return_none_when_last_provider_id_matches_given_id_and_date_modified_at_last_provider_is_none( ): # Given provider_id = 1 pc_object = Stock() pc_object.lastProviderId = provider_id pc_object.dateModifiedAtLastProvider = None # When date_modified_at_last_provider = get_last_update_for_provider( provider_id=provider_id, pc_obj=pc_object) # Then assert date_modified_at_last_provider is None
def test_get_last_update_for_provider_should_return_date_modified_at_last_provider_when_provided( ): # Given provider_id = 1 modification_date = datetime(2019, 1, 1) pc_object = Stock() pc_object.lastProviderId = provider_id pc_object.dateModifiedAtLastProvider = modification_date # When date_modified_at_last_provider = get_last_update_for_provider( provider_id=provider_id, pc_obj=pc_object) # Then assert date_modified_at_last_provider == modification_date
def create_stock_with_event_offer( offerer: Offerer, venue: Venue, price: int = 10, booking_email: str = "*****@*****.**", quantity: int = 10, is_soft_deleted: bool = False, event_type: EventType = EventType.JEUX, name: str = "Mains, sorts et papiers", offer_id: int = None, beginning_datetime: datetime = datetime.utcnow() + timedelta(hours=72), thumb_count: int = 0, booking_limit_datetime: datetime = datetime.utcnow() + timedelta(hours=71), date_created: datetime = datetime.utcnow(), date_modified_at_last_provider: datetime = datetime.utcnow(), date_modifed: datetime = datetime.utcnow(), ) -> Stock: stock = Stock() stock.offerer = offerer stock.price = price stock.quantity = quantity stock.beginningDatetime = beginning_datetime stock.bookingLimitDatetime = booking_limit_datetime stock.dateCreated = date_created stock.dateModifiedAtLastProvider = date_modified_at_last_provider stock.dateModified = date_modifed stock.offer = create_offer_with_event_product( venue, event_name=name, event_type=event_type, booking_email=booking_email, is_national=False, thumb_count=thumb_count, ) stock.offer.id = offer_id stock.isSoftDeleted = is_soft_deleted return stock