"""Base test cases for testing brainstormers."""

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

from ..factories import BrainstormerActivityFactory, BrainstormerTemplateFactory


class BaseBrainstormerTestCase:
    """Base test case to tests brainstormer.

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

    Attributes
    ----------
    brainstormer: ``mtp.apps.brainstormers.models.Brainstormer``
        A brainstormer template instance

    """

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

        super().setUpTestData()

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

            cls.brainstormer = BrainstormerTemplateFactory(training=cls.training)


class BrainstormerTestCase(BaseBrainstormerTestCase, MTPTestCase):
    """A test case based on ``BaseBrainstormerTestCase`` and ``MTPTestCase``.

    Should be used in most cases.

    """


class BaseBrainstormerActivityTestCase:
    """Base test case to tests brainstormer activity.

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

    Attributes
    ----------
    brainstormer_activity: ``mtp.apps.brainstormers.models.BrainstormerActivity``
        A brainstormer activity instance

    """

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

        super().setUpTestData()

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

            cls.brainstormer_activity = BrainstormerActivityFactory()
            cls.training.brainstormeractivity_set.add(cls.brainstormer_activity)


class BrainstormerActivityTestCase(BaseBrainstormerActivityTestCase, MTPTestCase):
    """A test case based on ``BaseBrainstormerActivityTestCase`` and ``MTPTestCase``.

    Should be used in most cases.

    """
