"""This module contains the tests for the views of the ``brainstormers`` app"""

from ..factories import BrainstormerFactory, BrainstormerPropositionGroupFactory

from .test_cases import BrainstormerTestCase


class BrainstormerViewTestCase(BrainstormerTestCase):
    """Test the views related to the ``Brainstormer`` model"""

    @classmethod
    def setUpTestData(cls):
        """Set up the test data"""
        super().setUpTestData()

        # We will need a brainstormer for the session
        cls.brainstormer = BrainstormerFactory()
        cls.group = BrainstormerPropositionGroupFactory(brainstormer=cls.brainstormer)

    def test_all_routes_should_work(self):
        """Test the response_code of all the brainstormer related routes"""

        self.login_as_trainer()

        urls_to_test = [
            self.training_session.get_brainstormer_list_url(),
            self.training_session.get_brainstormer_import_url(),
            self.training_session.get_brainstormer_create_url(),
            self.brainstormer.get_detail_url(),
            self.brainstormer.get_update_url(),
            self.brainstormer.get_delete_url(),
            self.brainstormer.get_export_xls_url(),
            self.brainstormer.get_export_csv_url(),
            self.group.get_create_proposition_url(),
        ]

        for url in urls_to_test:
            response = self.client.get(url)
            self.assertEqual(response.status_code, 200)
