"""This module holds the test for the views of the ``evaluations`` app."""

from .test_cases import EvaluationTestCase

class EvaluationEditViewsTestCase(EvaluationTestCase):
    """Test the edit views of the evaluation"""

    @classmethod
    def setUpTestData(cls):
        """Setup the test data"""

        super().setUpTestData()

        cls.urls_to_test = [
            cls.evaluation.get_absolute_url(),
            cls.evaluation.get_detail_url(),
            cls.evaluation.get_edit_url(),
            cls.evaluation.get_exercise_create_url(),
            cls.evaluation.get_exercises_sort_url(),
            cls.evaluation.get_create_url(training=cls.training),
        ]

    def test_all_routes_should_work_as_the_owner(self):
        """Test the response_code of all the evaluations routes, as the owner"""

        self.login_as_trainer()

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

    def test_all_routes_should_be_404_as_the_non_owner(self):
        """Test the response_code of all the evaluations routes, as a non-owner"""

        self.login_as_admin()

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

