import factory

from mtp.apps.accounts.factories import JobProfileFactory
from mtp.apps.assessments.factories import CertificationProgramUserStatusFactory

from ..factories.competencies import DimensionFactory
from ..models import (
    Curriculum,
    Lesson,
    LessonDimensionWeight,
    LessonRecommendationThreshold,
    RecommendationLevel,
    Topic,
    UserLessonRecommendation,
)


class RecommendationLevelFactory(factory.django.DjangoModelFactory):

    class Meta:
        model = RecommendationLevel

    name = factory.Sequence(lambda n: 'Level %d' % n)


class CurriculumFactory(factory.django.DjangoModelFactory):

    class Meta:
        model = Curriculum

    name = factory.Sequence(lambda n: 'curriculum-%d' % n)
    job_profile = factory.SubFactory(JobProfileFactory)


class TopicFactory(factory.django.DjangoModelFactory):

    class Meta:
        model = Topic

    name = factory.Sequence(lambda n: 'topic-%d' % n)
    curriculum = factory.SubFactory(CurriculumFactory)


class LessonFactory(factory.django.DjangoModelFactory):

    class Meta:
        model = Lesson

    name = factory.Sequence(lambda n: 'lesson-%d' % n)
    curriculum = factory.SubFactory(CurriculumFactory)
    topic = factory.SubFactory(TopicFactory)


class LessonDimensionWeightFactory(factory.django.DjangoModelFactory):

    class Meta:
        model = LessonDimensionWeight

    lesson = factory.SubFactory(LessonFactory)
    dimension = factory.SubFactory(DimensionFactory)


class LessonRecommendationThresholdFactory(factory.django.DjangoModelFactory):

    class Meta:
        model = LessonRecommendationThreshold

    lesson = factory.SubFactory(LessonFactory)
    level = factory.SubFactory(RecommendationLevelFactory)


class UserLessonRecommendationFactory(factory.django.DjangoModelFactory):

    class Meta:
        model = UserLessonRecommendation

    certification = factory.SubFactory(CertificationProgramUserStatusFactory)
    lesson = factory.SubFactory(LessonFactory)
    level = factory.SubFactory(RecommendationLevelFactory)
    score = 0
