""" This module holds the tests managers of the ``brainstormers`` app. """

from mtp.apps.brainstormers.factories import BrainstormerFactory
from mtp.apps.brainstormers.models import Brainstormer
from mtp.apps.common.tests.test_cases import MTPTestCase
from mtp.apps.trainings.factories import TrainingSessionFactory


class BrainstormerManagerTestCase(MTPTestCase):
    """ Test case that tests the ``Brainstormer`` manager. """

    @classmethod
    def setUpTestData(cls):
        super().setUpTestData()

        cls.other_training_session = TrainingSessionFactory()

        cls.brainstormer1 = BrainstormerFactory(session=cls.training_session)
        cls.brainstormer2 = BrainstormerFactory(session=cls.other_training_session)

    def test_queryset_filter_on_training_session(self):
        """ Test the filter on training_session. """
        queryset = Brainstormer.objects.for_training_session(self.training_session)
        self.assertEqual(queryset.count(), 1)
        self.assertEqual(queryset.first(), self.brainstormer1)

        queryset = Brainstormer.objects.for_training_session(self.other_training_session)
        self.assertEqual(queryset.count(), 1)
        self.assertEqual(queryset.first(), self.brainstormer2)
