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

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

from ..factories import (
    BrainstormerTemplateFactory,
    BrainstormerFactory,
    BrainstormerPropositionFactory,
    BrainstormerPropositionGroupFactory
)


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_template = BrainstormerTemplateFactory(training=cls.training)

        cls.brainstormer = BrainstormerFactory(session=cls.training_session)
        cls.group = BrainstormerPropositionGroupFactory(brainstormer=cls.brainstormer)
        cls.proposition = BrainstormerPropositionFactory(brainstormer=cls.brainstormer)
        cls.proposition.groups.add(cls.group)


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

    Should be used in most cases.

    """
