""" This module holds the factories for the ``metaplans`` app. """

import factory

from mtp.apps.accounts.factories import TraineeFactory
from mtp.apps.trainings.factories import TrainingSessionFactory

from .models import Metaplan, MetaplanProposition


class MetaplanFactory(factory.django.DjangoModelFactory):
    """ Factory for the ``mtp.apps.metaplans.models.Metaplan`` model.

    Attributes
    ----------
    name : ``factory.Sequence``
    session : sub-factory of ``mtp.apps.trainings.factories.TrainingSessionFactory``

    """

    class Meta:
        model = Metaplan

    name = factory.Sequence(lambda n: 'Metaplan-%d' % n)
    session = factory.SubFactory(TrainingSessionFactory)


class MetaplanPropositionFactory(factory.django.DjangoModelFactory):
    """ Factory for the ``mtp.apps.metaplans.models.MetaplanProposition`` model.

    Attributes
    ----------
    metaplan : sub-factory of ``mtp.apps.training.factories.MetaplanFactory``
    group : ``factory.Sequence``
    user : sub-factory of ``mtp.apps.training.factories.TraineeFactory``
    text : ``factory.Sequence``

    """

    class Meta:
        model = MetaplanProposition

    metaplan = factory.SubFactory(MetaplanFactory)
    group = factory.Sequence(lambda n: n % 4)
    user = factory.SubFactory(TraineeFactory)
    text = factory.Sequence(lambda n: 'text-proposition-%d' % n)
