import factory
import factory.fuzzy

from mtp.apps.accounts.factories import TraineeFactory

from ..factories.competencies import CompetencyFactory, CompetencyTreeFactory
from ..models import (
    CertificationCompetencyThreshold,
    CertificationProgram,
    CertificationProgramUserStatus,
    CertificationStatus,
)


class CertificationProgramFactory(factory.django.DjangoModelFactory):

    class Meta:
        model = CertificationProgram

    name = factory.Sequence(lambda n: 'program-%d' % n)
    tree = factory.SubFactory(CompetencyTreeFactory)


class CertificationStatusFactory(factory.django.DjangoModelFactory):

    class Meta:
        model = CertificationStatus

    name = factory.Sequence(lambda n: 'status-%d' % n)
    program = factory.SubFactory(CertificationProgramFactory)


class CertificationCompetencyThresholdFactory(factory.django.DjangoModelFactory):

    class Meta:
        model = CertificationCompetencyThreshold

    status = factory.SubFactory(CertificationStatusFactory)
    competency = factory.SubFactory(CompetencyFactory)


class CertificationProgramUserStatusFactory(factory.django.DjangoModelFactory):

    class Meta:
        model = CertificationProgramUserStatus

    user = factory.SubFactory(TraineeFactory)
    status = factory.SubFactory(CertificationStatusFactory)
    score = factory.fuzzy.FuzzyInteger(50)
