"""Fixture for the highlight model.""" import factory from marketing.models import highlight class HighlightFactory(factory.Factory): """Highlight factory class.""" class Meta: """Meta class representing the model.""" model = highlight.Highlight highlight_id = factory.Sequence(lambda number: number) mkt_program_id = factory.Sequence(lambda number: number) entity = factory.Iterator(highlight.ENTITY_TYPES) entity_id = factory.Sequence(lambda number: number) subject = factory.Faker('text') description = factory.Faker('text') attachment = factory.Iterator(highlight.ATTACHMENT) date_added = factory.Faker('date_time') last_updated = factory.Faker('date_time') scope = factory.Iterator(highlight.SCOPES) client = factory.Iterator(highlight.CLIENTS) def get_data_sample(**data): """Create a sample of a marketing highlight. Args: data (dict): optional dataset. Returns: dict (dict): the model dataset. """ data = HighlightFactory.build(**data) return { 'mkt_program_id': data.mkt_program_id, 'entity': data.entity, 'entity_id': data.entity_id, 'subject': data.subject, 'description': data.description, 'attachment': data.attachment, 'scope': data.scope, 'client': data.client } def get_sample(**data): """Create a sample of a marketing highlight (and save it). Args: data (dict): optional dataset. Returns: Response: contains the newly created highlight. """ sample = get_data_sample(**data) return highlight.create_marketing_highlight(**sample) def get_samples(count, **data): """Create samples of a marketing highlight (and save it). Args: count (int): the number of samples to create. data (dict): optional dataset. Returns: list: response that contains the highlight object. """ return [ highlight.create_marketing_highlight(**get_data_sample(**data)) for item in range(count)]