"""Base test cases for testing metaplans."""

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

from ..factories import MetaplanTemplateFactory


class BaseMetaplanTestCase:
    """Base test case to tests metaplan.

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

    Attributes
    ----------
    metaplan: ``mtp.apps.metaplans.models.MetaplanTemplate``
        A metaplan template instance

    """

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

        super().setUpTestData()

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

            cls.metaplan_template = MetaplanTemplateFactory(training=cls.training)


class MetaplanTestCase(BaseMetaplanTestCase, MTPTestCase):
    """A test case based on ``BaseMetaplanTestCase`` and ``MTPTestCase``.

    Should be used in most cases.

    """
