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

import factory

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

from .models import (
    Photo,
    Strip,
    Photostory
)


class PhotostoryFactory(factory.django.DjangoModelFactory):
    """Factory for the ``Photostory`` model.

    Attributes
    ----------
    name : ``factory.Sequence``

    """

    class Meta:
        model = Photostory
        django_get_or_create = ('name',)

    name = factory.Sequence(lambda n: 'Photostory-%d' % n)
    training = factory.SubFactory(TrainingFactory)


class StripFactory(factory.django.DjangoModelFactory):
    """Factory for the ``Strip`` model.

    Attributes
    ----------
    name : ``factory.Sequence``

    """

    class Meta:
        model = Strip
        django_get_or_create = ('name',)

    name = factory.Sequence(lambda n: 'Strip-%d' % n)
    owner = factory.SubFactory(TraineeFactory)
    photostory = factory.SubFactory(PhotostoryFactory)
    session = factory.SubFactory(TrainingSessionFactory)


class PhotoFactory(factory.django.DjangoModelFactory):
    """Factory for the ``Photo`` model.

    Attributes
    ----------
    image : ``factory.django.ImageField``

    """

    class Meta:
        model = Photo

    image = factory.django.ImageField(color='blue')
    strip = factory.SubFactory(StripFactory)
