예제 #1
0
def create_product_with_event_type(
        event_name='Test event',
        event_type=EventType.SPECTACLE_VIVANT,
        description=None,
        dominant_color=None,
        duration_minutes=60,
        is_national=False,
        thumb_count=0,
) -> Product:
    product = Product()
    product.name = event_name
    product.description = description
    product.durationMinutes = duration_minutes
    product.thumbCount = thumb_count
    product.isNational = is_national
    product.type = str(event_type)
    product.firstThumbDominantColor = dominant_color
    if product.thumbCount > 0 and not dominant_color:
        product.firstThumbDominantColor = b'\x00\x00\x00'
    product.description = description
    return product
예제 #2
0
def create_product_with_thing_type(
        thing_name='Test Book',
        thing_type=ThingType.LIVRE_EDITION,
        author_name='Test Author',
        is_national=False,
        id_at_providers=None,
        date_modified_at_last_provider=None,
        last_provider_id=None,
        media_urls=['test/urls'],
        description=None,
        dominant_color=None,
        thumb_count=1,
        url=None,
        owning_offerer=None,
) -> Product:
    product = Product()
    product.type = str(thing_type)
    product.name = thing_name
    product.description = description
    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.mediaUrls = media_urls
    product.thumbCount = thumb_count
    product.url = url
    product.owningOfferer = owning_offerer

    if thumb_count > 0:
        if dominant_color is None:
            product.firstThumbDominantColor = b'\x00\x00\x00'
        else:
            product.firstThumbDominantColor = dominant_color
    product.description = description
    return product