"""This module contains the base test cases for the ``ideas`` app"""

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

from ..factories import (
    BrainstormingFactory,
    BrainstormingIdeaFactory,
    BrainstormingTagFactory,
    QuestionWallFactory,
    WordCloudFactory
)


class BaseIdeasTestCase:
    """Base test case for the ``ideas`` app related tests.

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

    Attributes
    ----------
    brainstorming: ``mtp.apps.ideas.models.Brainstorming``
        A brainstorming instance
    brainstorming_tag: ``mtp.apps.ideas.models.BrainstormingTag``
        A tag linked to the brainstorming
    brainstorming_idea: ``mtp.apps.ideas.models.BrainstormingIdea``
        An idea linked to the tag and the brainstorming
    questionwall: ``mtp.apps.ideas.models.QuestionWall``
        A questionwall instance
    wordcloud: ``mtp.apps.ideas.models.WordCloud``
        A wordcloud instance

    """

    @classmethod
    def setUpTestData(cls):
        """Create some data to use in the ``ideas`` related tests."""

        super().setUpTestData()

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

            # Data related to the ``Brainstorming`` model
            cls.brainstorming = BrainstormingFactory(training=cls.training)
            cls.brainstorming_tag = BrainstormingTagFactory(brainstorming=cls.brainstorming)
            cls.brainstorming_idea = BrainstormingIdeaFactory(brainstorming=cls.brainstorming)
            cls.brainstorming_idea.tags.add(cls.brainstorming_tag)

            # Data related to the ``QuestionWall`` model
            cls.questionwall = QuestionWallFactory(training=cls.training)

            # Data related to the ``WordCloud`` model
            cls.wordcloud = WordCloudFactory(training=cls.training)


class IdeasTestCase(BaseIdeasTestCase, MTPTestCase):
    """A test case based on ``BaseIdeasTestCase`` and ``MTPTestCase``.

    Should be used in most cases.

    """

    pass
