import datetime
import random

import factory
from factory.fuzzy import FuzzyDateTime
from pytz import UTC

from core.factories import fake, fake_title
from news.models import NewsTeaser


class NewsTeaserFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = NewsTeaser

    title = factory.LazyAttribute(lambda x: fake_title(max_words=2))
    description = factory.LazyAttribute(lambda x: fake.sentence(nb_words=random.randint(4, 8)))
    image_url = factory.LazyAttribute(lambda x: 'https://picsum.photos/550/257/?random')
    news_article_url = factory.LazyAttribute(lambda x: 'https://myskillbox-abu-news.webflow.io/brexit')
    date = FuzzyDateTime(datetime.datetime(2020, 1, 1, tzinfo=UTC))
    image_source = factory.LazyAttribute(lambda x: 'https://picsum.photos/550/257/?random')
