import random

import factory
from django.contrib.auth import get_user_model

from books.factories import ModuleFactory
from core.factories import fake
from objectives.models import ObjectiveGroup, Objective


class ObjectiveGroupFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = ObjectiveGroup

    title = factory.Iterator([ObjectiveGroup.LANGUAGE_COMMUNICATION, ObjectiveGroup.SOCIETY])

    module = factory.SubFactory(ModuleFactory)


class ObjectiveFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Objective

    text = factory.LazyAttribute(lambda x: fake.sentence(nb_words=random.randint(4, 8)))

    group = factory.SubFactory(ObjectiveGroupFactory)


# class ObjectiveProgressStatusFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = ObjectiveProgressStatus
#
#     objective = factory.SubFactory(ObjectiveFactory)
#     user = factory.Iterator(get_user_model().objects.all())
#
#     done = factory.Sequence([True, False])
