"""Base test cases for testing roleplays."""

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

from ..factories import CriterionFactory, RoleplayFactory, StepFactory
from ..models import Criterion


class BaseRoleplayTestCase:
    """Base test case to tests roleplays.

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

    Attributes
    ----------
    roleplay: ``mtp.apps.roleplays.models.Roleplay``
        A roleplay containing 3 ``mtp.apps.roleplays.models.Step``, each step
        containing 12 ``mtp.apps.roleplays.models.Criterion``.

    """

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

        super().setUpTestData()

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

            cls.roleplay = RoleplayFactory(training=cls.training)
            for step in StepFactory.create_batch(3, roleplay=cls.roleplay):
                CriterionFactory.create_batch(12, step=step)
                CriterionFactory.create_batch(12, step=step,
                                              criterion_type=Criterion.CRITERION_TYPES.BOOLEAN)
                CriterionFactory.create_batch(12, step=step,
                                              criterion_type=Criterion.CRITERION_TYPES.QUALITATIVE)


class RoleplayTestCase(BaseRoleplayTestCase, MTPTestCase):
    """A test case based on ``BaseRoleplayTestCase`` and ``MTPTestCase``.

    Should be used in most cases.

    """
