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

import factory
import factory.fuzzy

from .models import (
    BackgroundExecution, Document, Note
)

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


class DocumentFactory(factory.django.DjangoModelFactory):
    """Factory for the ``Document`` model."""

    class Meta:
        model = Document

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

    trainer_document_file = factory.django.FileField()
    trainee_document_file = factory.django.FileField()


class NoteFactory(factory.django.DjangoModelFactory):
    """Factory for the ``Note`` model."""

    class Meta:
        model = Note

    user = factory.SubFactory(TraineeFactory)
    session = factory.SubFactory(TrainingSessionFactory)
    page = factory.fuzzy.FuzzyInteger(0, 20)
    coord_x = factory.fuzzy.FuzzyFloat(10)
    coord_y = factory.fuzzy.FuzzyFloat(10)
    width = factory.fuzzy.FuzzyFloat(10)
    height = factory.fuzzy.FuzzyFloat(10)
    text = factory.Sequence(lambda n: 'text-%d' % n)
    note_type = factory.Sequence(lambda n: 'type-%d' % n)


class BackgroundExecutionFactory(factory.django.DjangoModelFactory):
    """Factory for the ``BackgroundExecution`` model."""

    class Meta:
        model = BackgroundExecution
