Example #1
0
    def test_check_postponement_conflict_learning_unit_year_case_language_diff(
            self):
        # Copy the same learning unit year + change academic year, language
        another_learning_unit_year = _build_copy(self.learning_unit_year)
        another_learning_unit_year.academic_year = self.next_academic_year
        another_learning_unit_year.language = LanguageFactory(code='FR',
                                                              name='French')
        another_learning_unit_year.save()

        error_list = business_edition._check_postponement_conflict_on_learning_unit_year(
            self.learning_unit_year, another_learning_unit_year)
        self.assertIsInstance(error_list, list)
        self.assertEqual(len(error_list), 1)
        generic_error = "The value of field '%(field)s' is different between year %(year)s - %(value)s " \
                        "and year %(next_year)s - %(next_value)s"

        # Error : Language diff
        error_language = _(generic_error) % {
            'field': _('language'),
            'year': self.learning_container_year.academic_year,
            'value': getattr(self.learning_unit_year, 'language'),
            'next_year': another_learning_unit_year.academic_year,
            'next_value': getattr(another_learning_unit_year, 'language')
        }
        self.assertIn(error_language, error_list)
Example #2
0
    def test_check_postponement_conflict_learning_unit_year_differences_found(
            self):
        # Copy the same learning unit + change academic year / acronym / specific_title_english
        another_learning_unit_year = _build_copy(self.learning_unit_year)
        another_learning_unit_year.academic_year = self.next_academic_year
        another_learning_unit_year.acronym = 'LBIR1000'
        another_learning_unit_year.specific_title_english = None  # Remove value
        another_learning_unit_year.save()

        error_list = business_edition._check_postponement_conflict_on_learning_unit_year(
            self.learning_unit_year, another_learning_unit_year)
        self.assertIsInstance(error_list, list)
        self.assertEqual(len(error_list), 2)
        generic_error = "The value of field '%(field)s' is different between year %(year)s - %(value)s " \
                        "and year %(next_year)s - %(next_value)s"
        # Error : Acronym diff
        error_acronym = _(generic_error) % {
            'field': _('acronym'),
            'year': self.learning_unit_year.academic_year,
            'value': getattr(self.learning_unit_year, 'acronym'),
            'next_year': another_learning_unit_year.academic_year,
            'next_value': getattr(another_learning_unit_year, 'acronym')
        }
        self.assertIn(error_acronym, error_list)
        # Error : Specific title english diff
        error_specific_title_english = _(generic_error) % {
            'field': _('english_title_proper_to_UE'),
            'year': self.learning_unit_year.academic_year,
            'value': getattr(self.learning_unit_year,
                             'specific_title_english'),
            'next_year': another_learning_unit_year.academic_year,
            'next_value': _('no_data')
        }
        self.assertIn(error_specific_title_english, error_list)
Example #3
0
    def test_check_postponement_conflict_learning_unit_year_no_differences(self):
        # Copy the same learning unit + change academic year
        another_learning_unit_year = _build_copy(self.learning_unit_year)
        another_learning_unit_year.academic_year = self.next_academic_year
        another_learning_unit_year.save()

        error_list = business_edition._check_postponement_conflict_on_learning_unit_year(self.learning_unit_year,
                                                                                         another_learning_unit_year)
        self.assertIsInstance(error_list, list)
        self.assertFalse(error_list)
Example #4
0
    def test_check_postponement_conflict_learning_unit_year_status_diff(self):
        # Copy the same learning unit + change academic year / acronym / specific_title_english
        another_learning_unit_year = _build_copy(self.learning_unit_year)
        another_learning_unit_year.academic_year = self.next_academic_year
        another_learning_unit_year.status = False
        another_learning_unit_year.save()

        error_list = business_edition._check_postponement_conflict_on_learning_unit_year(
            self.learning_unit_year, another_learning_unit_year)
        self.assertIsInstance(error_list, list)
        self.assertEqual(len(error_list), 1)
        generic_error = "The value of field '%(field)s' is different between year %(year)s - %(value)s " \
                        "and year %(next_year)s - %(next_value)s"
        # Error : Status diff
        error_status = _(generic_error) % {
            'field': _('status'),
            'year': self.learning_unit_year.academic_year,
            'value': _('yes'),
            'next_year': another_learning_unit_year.academic_year,
            'next_value': _('no')
        }
        self.assertIn(error_status, error_list)
Example #5
0
    def test_check_postponement_conflict_learning_unit_year_case_camp_diff(
            self):
        # Copy the same container + change academic year + campus
        another_learning_unit_year = _build_copy(self.learning_unit_year)
        another_learning_unit_year.academic_year = self.next_academic_year
        another_learning_unit_year.campus = CampusFactory(name='Paris')
        another_learning_unit_year.save()

        error_list = business_edition._check_postponement_conflict_on_learning_unit_year(
            self.learning_unit_year, another_learning_unit_year)
        self.assertIsInstance(error_list, list)
        self.assertEqual(len(error_list), 1)
        generic_error = "The value of field '%(field)s' is different between year %(year)s - %(value)s " \
                        "and year %(next_year)s - %(next_value)s"

        # Error : Campus diff
        error_campus = _(generic_error) % {
            'field': _('campus'),
            'year': self.learning_unit_year.academic_year,
            'value': getattr(self.learning_unit_year, 'campus'),
            'next_year': another_learning_unit_year.academic_year,
            'next_value': getattr(another_learning_unit_year, 'campus')
        }
        self.assertIn(error_campus, error_list)