"""Base test cases for testing evaluations."""

from mtp.apps.common.tests.test_cases import MTPTestCase

from ..factories import CriterionFactory, EvaluationFactory, ExerciseFactory
from ..models import Criterion


class BaseEvaluationTestCase:
    """Base test case to tests evaluations.

    It provides some default test data useful in a lot of tests.

    Attributes
    ----------
    evaluation: ``mtp.apps.evaluations.models.Evaluation``
        An evaluation containing 3 ``mtp.apps.evaluations.models.Exercise``,
        each one containing 12 ``mtp.apps.evaluations.models.Criterion``.

    """

    @classmethod
    def setUpTestData(cls):
        """Create some data to use in evaluations tests."""

        super().setUpTestData()

        with cls.training.override_version_state(cls.training.VERSION_STATES.DRAFT):

            cls.evaluation = EvaluationFactory(training=cls.training)
            for exercise in ExerciseFactory.create_batch(3, evaluation=cls.evaluation):
                for criterion_type in [
                        Criterion.CRITERION_TYPES.QUALITATIVE,
                        Criterion.CRITERION_TYPES.QUANTITATIVE,
                ]:
                    CriterionFactory.create_batch(
                        6, exercise=exercise, criterion_type=criterion_type
                    )


class EvaluationTestCase(BaseEvaluationTestCase, MTPTestCase):
    """A test case based on ``BaseEvaluationTestCase`` and ``MTPTestCase``.

    Should be used in most cases.

    """
